bpo-32663 Make SMTPUTF8SimTests run (GH-5314) (#8470) · python/cpython@cecbe0a
@@ -1068,6 +1068,19 @@ def test_send_unicode_without_SMTPUTF8(self):
10681068self.assertRaises(UnicodeEncodeError, smtp.sendmail, 'Alice', 'Böb', '')
10691069self.assertRaises(UnicodeEncodeError, smtp.mail, 'Älice')
107010701071+def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
1072+# This test is located here and not in the SMTPUTF8SimTests
1073+# class because it needs a "regular" SMTP server to work
1074+msg = EmailMessage()
1075+msg['From'] = "Páolo <főo@bar.com>"
1076+msg['To'] = 'Dinsdale'
1077+msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
1078+smtp = smtplib.SMTP(
1079+HOST, self.port, local_hostname='localhost', timeout=3)
1080+self.addCleanup(smtp.close)
1081+with self.assertRaises(smtplib.SMTPNotSupportedError):
1082+smtp.send_message(msg)
1083+10711084def test_name_field_not_included_in_envelop_addresses(self):
10721085smtp = smtplib.SMTP(
10731086HOST, self.port, local_hostname='localhost', timeout=3
@@ -1213,17 +1226,6 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
12131226self.assertIn('SMTPUTF8', self.serv.last_mail_options)
12141227self.assertEqual(self.serv.last_rcpt_options, [])
121512281216-def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
1217-msg = EmailMessage()
1218-msg['From'] = "Páolo <főo@bar.com>"
1219-msg['To'] = 'Dinsdale'
1220-msg['Subject'] = 'Nudge nudge, wink, wink \u1F609'
1221-smtp = smtplib.SMTP(
1222-HOST, self.port, local_hostname='localhost', timeout=3)
1223-self.addCleanup(smtp.close)
1224-self.assertRaises(smtplib.SMTPNotSupportedError,
1225-smtp.send_message(msg))
1226-1227122912281230EXPECTED_RESPONSE = encode_base64(b'\0psu\0doesnotexist', eol='')
12291231@@ -1292,18 +1294,5 @@ def testAUTH_PLAIN_initial_response_auth(self):
12921294self.assertEqual(code, 235)
12931295129412961295-@support.reap_threads
1296-def test_main(verbose=None):
1297-support.run_unittest(
1298-BadHELOServerTests,
1299-DebuggingServerTests,
1300-GeneralTests,
1301-NonConnectingTests,
1302-SMTPAUTHInitialResponseSimTests,
1303-SMTPSimTests,
1304-TooLongLineTests,
1305- )
1306-1307-13081297if __name__ == '__main__':
1309-test_main()
1298+unittest.main()