Commit 1660933d authored by Facundo Batista's avatar Facundo Batista

Issue 1776581. Minor corrections to smtplib, and two small tests.

Thanks Alan McIntyre.
parent fc2d0103
......@@ -298,7 +298,7 @@ class SMTP:
def send(self, str):
"""Send `str' to the server."""
if self.debuglevel > 0: print>>stderr, 'send:', repr(str)
if self.sock:
if hasattr(self, 'sock') and self.sock:
try:
self.sock.sendall(str)
except socket.error:
......@@ -486,7 +486,7 @@ class SMTP:
vrfy=verify
def expn(self, address):
"""SMTP 'verify' command -- checks for address validity."""
"""SMTP 'expn' command -- expands a mailing list."""
self.putcmd("expn", quoteaddr(address))
return self.getreply()
......
......@@ -82,8 +82,9 @@ class GeneralTests(TestCase):
# to reference the nonexistent 'sock' attribute of the SMTP object
# causes an AttributeError)
smtp = smtplib.SMTP()
self.assertRaises(AttributeError, smtp.ehlo)
self.assertRaises(AttributeError, smtp.send, 'test msg')
self.assertRaises(smtplib.SMTPServerDisconnected, smtp.ehlo)
self.assertRaises(smtplib.SMTPServerDisconnected,
smtp.send, 'test msg')
def testLocalHostName(self):
# check that supplied local_hostname is used
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment