Closes #19665: Merged fi from 3.3.
This commit is contained in:
commit
ef2d8a597c
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue