test_smtpnet: Skip STARTTLS test if the server doesn't support it.

This issue can arise with ISPs that redirect all connections on port 25 to
their own (crappy) mail servers.
This commit is contained in:
Nadeem Vawda 2011-07-30 23:46:54 +02:00
parent 6e3b975aa5
commit 3fc5868a1d
1 changed files with 7 additions and 1 deletions

View File

@ -18,7 +18,13 @@ class SmtpTest(unittest.TestCase):
support.get_attribute(smtplib, 'SMTP_SSL')
with support.transient_internet(self.testServer):
server = smtplib.SMTP(self.testServer, self.remotePort)
try:
server.starttls(context=self.context)
except smtplib.SMTPException as e:
if e.args[0] == 'STARTTLS extension not supported by server.':
unittest.skip(e.args[0])
else:
raise
server.ehlo()
server.quit()