diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-07-30 10:56:50 +0800 |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-07-30 10:56:50 +0800 |
commit | 3d23fd649309fe80fdd1dee04b668fefb50c1b97 (patch) | |
tree | 912395e2e554691e6b32a3dbab7b1254a15381fc /Lib/test/test_smtplib.py | |
parent | f83e4acbaec012e01e11d5cc4ea6514cf2a7b34c (diff) | |
download | cpython-git-3d23fd649309fe80fdd1dee04b668fefb50c1b97.tar.gz |
Fix closes Issue11281 - smtplib.STMP gets source_address parameter, which adds the ability to bind to specific source address on a machine with multiple interfaces. Patch by Paulo Scardine.
Diffstat (limited to 'Lib/test/test_smtplib.py')
-rw-r--r-- | Lib/test/test_smtplib.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 9f8a05435f..70654c50cd 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -72,6 +72,14 @@ class GeneralTests(unittest.TestCase): smtp = smtplib.SMTP(HOST, self.port) smtp.close() + def testSourceAddress(self): + mock_socket.reply_with(b"220 Hola mundo") + # connects + smtp = smtplib.SMTP(HOST, self.port, + source_address=('127.0.0.1',19876)) + self.assertEqual(smtp.source_address, ('127.0.0.1', 19876)) + smtp.close() + def testBasic2(self): mock_socket.reply_with(b"220 Hola mundo") # connects, include port in host name @@ -206,6 +214,15 @@ class DebuggingServerTests(unittest.TestCase): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) smtp.quit() + 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() + def testNOOP(self): smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3) expected = (250, b'Ok') |