Addressing the review comments by Antoine Pitrou for smtplib.py and test_smtplib.py. Review comments by Ezio Melotti for smtplib.rst
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 70654c5..969ff15 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -216,12 +216,17 @@
def testSourceAddress(self):
# connect
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3,
- source_address=('127.0.0.1', 19876))
- self.assertEqual(smtp.source_address, ('127.0.0.1', 19876))
- self.assertEqual(smtp.local_hostname, 'localhost')
- print(dir(smtp))
- smtp.quit()
+ port = support.find_unused_port()
+ try:
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=3, source_address=('127.0.0.1', port))
+ self.assertEqual(smtp.source_address, ('127.0.0.1', port))
+ self.assertEqual(smtp.local_hostname, 'localhost')
+ smtp.quit()
+ except IOError as e:
+ if e.errno == errno.EADDRINUSE:
+ self.skipTest("couldn't bind to port %d" % port)
+ raise
def testNOOP(self):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)