]> granicus.if.org Git - python/commitdiff
test_smtpnet: Skip STARTTLS test if the server doesn't support it.
authorNadeem Vawda <nadeem.vawda@gmail.com>
Sat, 30 Jul 2011 21:46:54 +0000 (23:46 +0200)
committerNadeem Vawda <nadeem.vawda@gmail.com>
Sat, 30 Jul 2011 21:46:54 +0000 (23:46 +0200)
This issue can arise with ISPs that redirect all connections on port 25 to
their own (crappy) mail servers.

Lib/test/test_smtpnet.py

index 7d0fa98b7b1658ccf035d41bef572b35ca90fe2f..86224ef2e45beb669e3503f2300595bb515c1656 100644 (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)
-            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()