From 853c0f9d601ca23727e1519d9b2ee82ccb45989f Mon Sep 17 00:00:00 2001 From: R David Murray Date: Wed, 20 Mar 2013 21:54:05 -0400 Subject: #5713: fix timing issue in smtplib tests. --- Lib/test/test_smtplib.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 92f986b..e5df6c7 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -789,6 +789,7 @@ class SMTPSimTests(unittest.TestCase): # Issue 5713: make sure close, not rset, is called if we get a 421 error def test_421_from_mail_cmd(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) + smtp.noop() self.serv._SMTPchannel.mail_response = '421 closing connection' with self.assertRaises(smtplib.SMTPSenderRefused): smtp.sendmail('John', 'Sally', 'test message') @@ -797,6 +798,7 @@ class SMTPSimTests(unittest.TestCase): def test_421_from_rcpt_cmd(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) + smtp.noop() self.serv._SMTPchannel.rcpt_response = ['250 accepted', '421 closing'] with self.assertRaises(smtplib.SMTPRecipientsRefused) as r: smtp.sendmail('John', ['Sally', 'Frank', 'George'], 'test message') @@ -813,6 +815,7 @@ class SMTPSimTests(unittest.TestCase): super().found_terminator() self.serv.channel_class = MySimSMTPChannel smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) + smtp.noop() with self.assertRaises(smtplib.SMTPDataError): smtp.sendmail('John@foo.org', ['Sally@foo.org'], 'test message') self.assertIsNone(smtp.sock) -- cgit v0.12 From 03b0116c781f8b2b530c2452d25d9a372c8f3635 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Wed, 20 Mar 2013 22:11:40 -0400 Subject: #5712: Preemptively fix some other possible timing issues. --- Lib/test/test_smtplib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index e5df6c7..ec971ea 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -626,12 +626,12 @@ class SimSMTPChannel(smtpd.SMTPChannel): if self.rcpt_response is None: super().smtp_RCPT(arg) return - self.push(self.rcpt_response[self.rcpt_count]) self.rcpt_count += 1 + self.push(self.rcpt_response[self.rcpt_count-1]) def smtp_RSET(self, arg): - super().smtp_RSET(arg) self.rset_count += 1 + super().smtp_RSET(arg) def smtp_DATA(self, arg): if self.data_response is None: @@ -794,7 +794,7 @@ class SMTPSimTests(unittest.TestCase): with self.assertRaises(smtplib.SMTPSenderRefused): smtp.sendmail('John', 'Sally', 'test message') self.assertIsNone(smtp.sock) - self.assertEqual(self.serv._SMTPchannel.rcpt_count, 0) + self.assertEqual(self.serv._SMTPchannel.rset_count, 0) def test_421_from_rcpt_cmd(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) -- cgit v0.12 From 3030728138593557fee3a8e2e1ccb2375f8d649c Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 20 Mar 2013 19:28:19 -0700 Subject: Fix import --- Lib/threading.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/threading.py b/Lib/threading.py index 415a993..80dd51f 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -10,11 +10,10 @@ except ImportError: from time import time as _time from traceback import format_exc as _format_exc from _weakrefset import WeakSet +from itertools import islice as _islice try: - from _itertools import islice as _slice from _collections import deque as _deque except ImportError: - from itertools import islice as _islice from collections import deque as _deque # Note regarding PEP 8 compliant names -- cgit v0.12