From: Nadeem Vawda Date: Sat, 30 Jul 2011 21:46:54 +0000 (+0200) Subject: test_smtpnet: Skip STARTTLS test if the server doesn't support it. X-Git-Tag: v3.3.0a1~1796 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fc5868a1d123996936c2feb6625865f5bb88b37;p=python 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. --- diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py index 7d0fa98b7b..86224ef2e4 100644 --- a/Lib/test/test_smtpnet.py +++ b/Lib/test/test_smtpnet.py @@ -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) - server.starttls(context=self.context) + 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()