summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-10-27 19:47:30 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-10-27 19:47:30 (GMT)
commita763c06357bd080e9e0afc7f29a742d427f1ee05 (patch)
treee56ce63fd22339220ad010eaac68066fc4c6532a /Lib/test
parentb218d289e6f5ceeb7979528d5c10bfcfb378b0b6 (diff)
downloadcpython-a763c06357bd080e9e0afc7f29a742d427f1ee05.zip
cpython-a763c06357bd080e9e0afc7f29a742d427f1ee05.tar.gz
cpython-a763c06357bd080e9e0afc7f29a742d427f1ee05.tar.bz2
Suppress transient refleaks in test_smtplib.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_smtplib.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 9a498d2..9a492f6 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -39,17 +39,21 @@ def server(evt, buf, serv):
class GeneralTests(TestCase):
def setUp(self):
+ self._threads = test_support.threading_setup()
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(15)
self.port = test_support.bind_port(self.sock)
servargs = (self.evt, "220 Hola mundo\n", self.sock)
- threading.Thread(target=server, args=servargs).start()
+ self.thread = threading.Thread(target=server, args=servargs)
+ self.thread.start()
self.evt.wait()
self.evt.clear()
def tearDown(self):
self.evt.wait()
+ self.thread.join()
+ test_support.threading_cleanup(*self._threads)
def testBasic1(self):
# connects
@@ -142,12 +146,14 @@ class DebuggingServerTests(TestCase):
self.output = StringIO.StringIO()
sys.stdout = self.output
+ self._threads = test_support.threading_setup()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
self.port = test_support.find_unused_port()
self.serv = smtpd.DebuggingServer((HOST, self.port), ('nowhere', -1))
serv_args = (self.serv, self.serv_evt, self.client_evt)
- threading.Thread(target=debugging_server, args=serv_args).start()
+ self.thread = threading.Thread(target=debugging_server, args=serv_args)
+ self.thread.start()
# wait until server thread has assigned a port number
self.serv_evt.wait()
@@ -158,6 +164,8 @@ class DebuggingServerTests(TestCase):
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
+ self.thread.join()
+ test_support.threading_cleanup(*self._threads)
# restore sys.stdout
sys.stdout = self.old_stdout
@@ -253,17 +261,21 @@ class BadHELOServerTests(TestCase):
self.output = StringIO.StringIO()
sys.stdout = self.output
+ self._threads = test_support.threading_setup()
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(15)
self.port = test_support.bind_port(self.sock)
servargs = (self.evt, "199 no hello for you!\n", self.sock)
- threading.Thread(target=server, args=servargs).start()
+ self.thread = threading.Thread(target=server, args=servargs)
+ self.thread.start()
self.evt.wait()
self.evt.clear()
def tearDown(self):
self.evt.wait()
+ self.thread.join()
+ test_support.threading_cleanup(*self._threads)
sys.stdout = self.old_stdout
def testFailingHELO(self):
@@ -369,12 +381,14 @@ class SimSMTPServer(smtpd.SMTPServer):
class SMTPSimTests(TestCase):
def setUp(self):
+ self._threads = test_support.threading_setup()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
self.port = test_support.find_unused_port()
self.serv = SimSMTPServer((HOST, self.port), ('nowhere', -1))
serv_args = (self.serv, self.serv_evt, self.client_evt)
- threading.Thread(target=debugging_server, args=serv_args).start()
+ self.thread = threading.Thread(target=debugging_server, args=serv_args)
+ self.thread.start()
# wait until server thread has assigned a port number
self.serv_evt.wait()
@@ -385,6 +399,8 @@ class SMTPSimTests(TestCase):
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
+ self.thread.join()
+ test_support.threading_cleanup(*self._threads)
def testBasic(self):
# smoke test