mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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()
This commit is contained in:
parent
2b2758d0b3
commit
7b31397180
3 changed files with 11 additions and 1 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue