summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_smtplib.py
diff options
context:
space:
mode:
authorRomuald Brunet <romuald@chivil.com>2018-10-09 14:31:55 (GMT)
committerGiampaolo Rodola <g.rodola@gmail.com>2018-10-09 14:31:55 (GMT)
commit7b313971805ca9b53f181f7b97e5376d0b89dc06 (patch)
treeb20b1345e8991acc211fcafa2e7f8fd9f9317eb1 /Lib/test/test_smtplib.py
parent2b2758d0b30f4ed7d37319d6c18552eccbc8e7b7 (diff)
downloadcpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.zip
cpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.tar.gz
cpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.tar.bz2
bpo-32680 add default "sock" on SMTP objects (#5345)
By default the smtplib.SMTP objects did not have a sock attribute, it was only created during connect()
Diffstat (limited to 'Lib/test/test_smtplib.py')
-rw-r--r--Lib/test/test_smtplib.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 0c863ed..07d760b 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -602,6 +602,13 @@ class NonConnectingTests(unittest.TestCase):
self.assertRaises(OSError, smtplib.SMTP,
"localhost:bogus")
+ def testSockAttributeExists(self):
+ # check that sock attribute is present outside of a connect() call
+ # (regression test, the previous behavior raised an
+ # AttributeError: 'SMTP' object has no attribute 'sock')
+ with smtplib.SMTP() as smtp:
+ self.assertIsNone(smtp.sock)
+
class DefaultArgumentsTests(unittest.TestCase):