Closes #19665: Merged fi from 3.3.

This commit is contained in:
Vinay Sajip 2013-12-03 11:29:45 +00:00
commit ef2d8a597c
1 changed files with 4 additions and 2 deletions

View File

@ -912,19 +912,21 @@ if threading:
@unittest.skipUnless(threading, 'Threading required for this test.') @unittest.skipUnless(threading, 'Threading required for this test.')
class SMTPHandlerTest(BaseTest): class SMTPHandlerTest(BaseTest):
TIMEOUT = 8.0
def test_basic(self): def test_basic(self):
sockmap = {} sockmap = {}
server = TestSMTPServer(('localhost', 0), self.process_message, 0.001, server = TestSMTPServer(('localhost', 0), self.process_message, 0.001,
sockmap) sockmap)
server.start() server.start()
addr = ('localhost', server.port) addr = ('localhost', server.port)
h = logging.handlers.SMTPHandler(addr, 'me', 'you', 'Log', timeout=5.0) h = logging.handlers.SMTPHandler(addr, 'me', 'you', 'Log',
timeout=self.TIMEOUT)
self.assertEqual(h.toaddrs, ['you']) self.assertEqual(h.toaddrs, ['you'])
self.messages = [] self.messages = []
r = logging.makeLogRecord({'msg': 'Hello'}) r = logging.makeLogRecord({'msg': 'Hello'})
self.handled = threading.Event() self.handled = threading.Event()
h.handle(r) h.handle(r)
self.handled.wait(5.0) # 14314: don't wait forever self.handled.wait(self.TIMEOUT) # 14314: don't wait forever
server.stop() server.stop()
self.assertTrue(self.handled.is_set()) self.assertTrue(self.handled.is_set())
self.assertEqual(len(self.messages), 1) self.assertEqual(len(self.messages), 1)