[Python-checkins] bpo-32663 Make SMTPUTF8SimTests run (GH-5314) (#8470)

R. David Murray webhook-mailer at python.org
Thu Jul 26 10:02:27 EDT 2018


https://github.com/python/cpython/commit/cecbe0ade87360cd37cc1389fe33dd92f2cf52ba
commit: cecbe0ade87360cd37cc1389fe33dd92f2cf52ba
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: R. David Murray <rdmurray at bitdance.com>
date: 2018-07-26T10:02:22-04:00
summary:

bpo-32663 Make SMTPUTF8SimTests run (GH-5314) (#8470)

Enable and fix SMTPUTF8SimTests in test_smtplib.

The tests for SMTPUTF8SimTests in test_smtplib.py were not actually
being run because test_smtplib was still using the 'test_main' pattern,
and the class was never added to test_main.

Additionally, one of the tests needed to be moved to the non-UTF8 server
class because it relies on the server not being UTF-8 compatible (and it
had a bug in in).
(cherry picked from commit 48ed88a93bb0bbeaae9a4cfaa533e4edf13bcb51)

Co-authored-by: chason <chason at gmail.com>

files:
A Misc/NEWS.d/next/Tests/2018-01-25-18-10-47.bpo-32663.IKDsqu.rst
M Lib/test/test_smtplib.py

diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 67b3b478f76f..79b3bd436876 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -1068,6 +1068,19 @@ def test_send_unicode_without_SMTPUTF8(self):
         self.assertRaises(UnicodeEncodeError, smtp.sendmail, 'Alice', 'Böb', '')
         self.assertRaises(UnicodeEncodeError, smtp.mail, 'Älice')
 
+    def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
+        # This test is located here and not in the SMTPUTF8SimTests
+        # class because it needs a "regular" SMTP server to work
+        msg = EmailMessage()
+        msg['From'] = "Páolo <főo at bar.com>"
+        msg['To'] = 'Dinsdale'
+        msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
+        smtp = smtplib.SMTP(
+            HOST, self.port, local_hostname='localhost', timeout=3)
+        self.addCleanup(smtp.close)
+        with self.assertRaises(smtplib.SMTPNotSupportedError):
+            smtp.send_message(msg)
+
     def test_name_field_not_included_in_envelop_addresses(self):
         smtp = smtplib.SMTP(
             HOST, self.port, local_hostname='localhost', timeout=3
@@ -1213,17 +1226,6 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
         self.assertIn('SMTPUTF8', self.serv.last_mail_options)
         self.assertEqual(self.serv.last_rcpt_options, [])
 
-    def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
-        msg = EmailMessage()
-        msg['From'] = "Páolo <főo at bar.com>"
-        msg['To'] = 'Dinsdale'
-        msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
-        smtp = smtplib.SMTP(
-            HOST, self.port, local_hostname='localhost', timeout=3)
-        self.addCleanup(smtp.close)
-        self.assertRaises(smtplib.SMTPNotSupportedError,
-                          smtp.send_message(msg))
-
 
 EXPECTED_RESPONSE = encode_base64(b'\0psu\0doesnotexist', eol='')
 
@@ -1292,18 +1294,5 @@ def testAUTH_PLAIN_initial_response_auth(self):
         self.assertEqual(code, 235)
 
 
- at support.reap_threads
-def test_main(verbose=None):
-    support.run_unittest(
-        BadHELOServerTests,
-        DebuggingServerTests,
-        GeneralTests,
-        NonConnectingTests,
-        SMTPAUTHInitialResponseSimTests,
-        SMTPSimTests,
-        TooLongLineTests,
-        )
-
-
 if __name__ == '__main__':
-    test_main()
+    unittest.main()
diff --git a/Misc/NEWS.d/next/Tests/2018-01-25-18-10-47.bpo-32663.IKDsqu.rst b/Misc/NEWS.d/next/Tests/2018-01-25-18-10-47.bpo-32663.IKDsqu.rst
new file mode 100644
index 000000000000..8357284e5734
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-01-25-18-10-47.bpo-32663.IKDsqu.rst
@@ -0,0 +1,2 @@
+Making sure the `SMTPUTF8SimTests` class of tests gets run in
+test_smtplib.py.



More information about the Python-checkins mailing list