mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
#5713: fix timing issue in smtplib tests.
This commit is contained in:
parent
1f8a40b81d
commit
853c0f9d60
1 changed files with 3 additions and 0 deletions
|
@ -789,6 +789,7 @@ class SMTPSimTests(unittest.TestCase):
|
||||||
# Issue 5713: make sure close, not rset, is called if we get a 421 error
|
# Issue 5713: make sure close, not rset, is called if we get a 421 error
|
||||||
def test_421_from_mail_cmd(self):
|
def test_421_from_mail_cmd(self):
|
||||||
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
||||||
|
smtp.noop()
|
||||||
self.serv._SMTPchannel.mail_response = '421 closing connection'
|
self.serv._SMTPchannel.mail_response = '421 closing connection'
|
||||||
with self.assertRaises(smtplib.SMTPSenderRefused):
|
with self.assertRaises(smtplib.SMTPSenderRefused):
|
||||||
smtp.sendmail('John', 'Sally', 'test message')
|
smtp.sendmail('John', 'Sally', 'test message')
|
||||||
|
@ -797,6 +798,7 @@ class SMTPSimTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_421_from_rcpt_cmd(self):
|
def test_421_from_rcpt_cmd(self):
|
||||||
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
||||||
|
smtp.noop()
|
||||||
self.serv._SMTPchannel.rcpt_response = ['250 accepted', '421 closing']
|
self.serv._SMTPchannel.rcpt_response = ['250 accepted', '421 closing']
|
||||||
with self.assertRaises(smtplib.SMTPRecipientsRefused) as r:
|
with self.assertRaises(smtplib.SMTPRecipientsRefused) as r:
|
||||||
smtp.sendmail('John', ['Sally', 'Frank', 'George'], 'test message')
|
smtp.sendmail('John', ['Sally', 'Frank', 'George'], 'test message')
|
||||||
|
@ -813,6 +815,7 @@ class SMTPSimTests(unittest.TestCase):
|
||||||
super().found_terminator()
|
super().found_terminator()
|
||||||
self.serv.channel_class = MySimSMTPChannel
|
self.serv.channel_class = MySimSMTPChannel
|
||||||
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
|
||||||
|
smtp.noop()
|
||||||
with self.assertRaises(smtplib.SMTPDataError):
|
with self.assertRaises(smtplib.SMTPDataError):
|
||||||
smtp.sendmail('John@foo.org', ['Sally@foo.org'], 'test message')
|
smtp.sendmail('John@foo.org', ['Sally@foo.org'], 'test message')
|
||||||
self.assertIsNone(smtp.sock)
|
self.assertIsNone(smtp.sock)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue