Benjamin Peterson | 90f5ba5 | 2010-03-11 22:53:45 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
R. David Murray | 87e2074 | 2009-05-23 01:30:26 +0000 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | from test import support |
| 5 | import smtplib |
| 6 | |
R. David Murray | eccb2ce | 2009-05-23 02:36:15 +0000 | [diff] [blame] | 7 | support.requires("network") |
R. David Murray | 87e2074 | 2009-05-23 01:30:26 +0000 | [diff] [blame] | 8 | |
| 9 | class SmtpSSLTest(unittest.TestCase): |
| 10 | testServer = 'smtp.gmail.com' |
| 11 | remotePort = 465 |
| 12 | |
| 13 | def test_connect(self): |
R. David Murray | eccb2ce | 2009-05-23 02:36:15 +0000 | [diff] [blame] | 14 | support.get_attribute(smtplib, 'SMTP_SSL') |
Antoine Pitrou | 6003ff7 | 2010-10-13 17:14:16 +0000 | [diff] [blame] | 15 | with support.transient_internet(self.testServer): |
| 16 | server = smtplib.SMTP_SSL(self.testServer, self.remotePort) |
R. David Murray | 87e2074 | 2009-05-23 01:30:26 +0000 | [diff] [blame] | 17 | server.ehlo() |
| 18 | server.quit() |
| 19 | |
Antoine Pitrou | c1d5206 | 2011-05-07 19:39:37 +0200 | [diff] [blame] | 20 | def test_connect_default_port(self): |
| 21 | support.get_attribute(smtplib, 'SMTP_SSL') |
| 22 | with support.transient_internet(self.testServer): |
| 23 | server = smtplib.SMTP_SSL(self.testServer) |
| 24 | server.ehlo() |
| 25 | server.quit() |
| 26 | |
R. David Murray | 87e2074 | 2009-05-23 01:30:26 +0000 | [diff] [blame] | 27 | def test_main(): |
| 28 | support.run_unittest(SmtpSSLTest) |
| 29 | |
| 30 | if __name__ == "__main__": |
| 31 | test_main() |