mirror of
https://github.com/python/cpython.git
synced 2024-11-26 03:14:27 +08:00
Merged revisions 75849 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75849 | antoine.pitrou | 2009-10-27 20:47:30 +0100 (mar., 27 oct. 2009) | 3 lines Suppress transient refleaks in test_smtplib. ........
This commit is contained in:
parent
dc508d6bc3
commit
c3d47724c1
@ -47,17 +47,21 @@ def server(evt, buf, serv):
|
||||
class GeneralTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self._threads = support.threading_setup()
|
||||
self.evt = threading.Event()
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.settimeout(15)
|
||||
self.port = support.bind_port(self.sock)
|
||||
servargs = (self.evt, b"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()
|
||||
support.threading_cleanup(*self._threads)
|
||||
|
||||
def testBasic1(self):
|
||||
# connects
|
||||
@ -150,12 +154,14 @@ class DebuggingServerTests(TestCase):
|
||||
self.output = io.StringIO()
|
||||
sys.stdout = self.output
|
||||
|
||||
self._threads = support.threading_setup()
|
||||
self.serv_evt = threading.Event()
|
||||
self.client_evt = threading.Event()
|
||||
self.port = 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()
|
||||
@ -166,6 +172,8 @@ class DebuggingServerTests(TestCase):
|
||||
self.client_evt.set()
|
||||
# wait for the server thread to terminate
|
||||
self.serv_evt.wait()
|
||||
self.thread.join()
|
||||
support.threading_cleanup(*self._threads)
|
||||
# restore sys.stdout
|
||||
sys.stdout = self.old_stdout
|
||||
|
||||
@ -261,17 +269,21 @@ class BadHELOServerTests(TestCase):
|
||||
self.output = io.StringIO()
|
||||
sys.stdout = self.output
|
||||
|
||||
self._threads = support.threading_setup()
|
||||
self.evt = threading.Event()
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.settimeout(15)
|
||||
self.port = support.bind_port(self.sock)
|
||||
servargs = (self.evt, b"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()
|
||||
support.threading_cleanup(*self._threads)
|
||||
sys.stdout = self.old_stdout
|
||||
|
||||
def testFailingHELO(self):
|
||||
@ -377,12 +389,14 @@ class SimSMTPServer(smtpd.SMTPServer):
|
||||
class SMTPSimTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self._threads = support.threading_setup()
|
||||
self.serv_evt = threading.Event()
|
||||
self.client_evt = threading.Event()
|
||||
self.port = 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()
|
||||
@ -393,6 +407,8 @@ class SMTPSimTests(TestCase):
|
||||
self.client_evt.set()
|
||||
# wait for the server thread to terminate
|
||||
self.serv_evt.wait()
|
||||
self.thread.join()
|
||||
support.threading_cleanup(*self._threads)
|
||||
|
||||
def testBasic(self):
|
||||
# smoke test
|
||||
|
Loading…
Reference in New Issue
Block a user