2626from unittest .mock import Mock
2727
2828
29+
2930support .requires_working_socket (module = True )
3031
3132HOST = socket_helper .HOST
@@ -1393,11 +1394,6 @@ class SMTPUTF8SimTests(unittest.TestCase):
13931394
13941395 maxDiff = None
13951396
1396- def _is_local (self , date : str ) -> bool :
1397- dt = email .utils .parsedate_to_datetime (date )
1398- local_offset = dt .now ().astimezone ().utcoffset ()
1399- return dt .utcoffset () == local_offset
1400-
14011397 def setUp (self ):
14021398 self .thread_key = threading_helper .threading_setup ()
14031399 self .real_getfqdn = socket .getfqdn
@@ -1472,6 +1468,7 @@ def test_send_unicode_with_SMTPUTF8_via_low_level_API(self):
14721468 self .assertIn ('SMTPUTF8' , self .serv .last_mail_options )
14731469 self .assertEqual (self .serv .last_rcpt_options , [])
14741470
1471+ @support .run_with_tz ('UTC-2' )
14751472 def test_send_message_uses_smtputf8_if_addrs_non_ascii (self ):
14761473 msg = EmailMessage ()
14771474 msg ['From' ] = "Páolo <főo@bar.com>"
@@ -1491,7 +1488,10 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
14911488 last_message = self .serv .last_message .decode ()
14921489 date = email .message_from_string (last_message )['Date' ]
14931490 # asserts RFC 5322 section 3.3 4th Paragraph
1494- self .assertTrue (self ._is_local (date ))
1491+ self .assertEqual (
1492+ email .utils .parsedate_to_datetime (date ).tzname (),
1493+ "UTC+02:00"
1494+ )
14951495
14961496 expected = textwrap .dedent ("""\
14971497 From: Páolo <főo@bar.com>
0 commit comments