Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Convert to asserts
  • Loading branch information
StanFromIreland committed Nov 1, 2025
commit e4036f858f8ad56d0d9ba38c5fb2dac06cb9d215
4 changes: 1 addition & 3 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -5717,9 +5717,7 @@ def test_rfc2231_bad_character_in_encoding(self):

"""
msg = email.message_from_string(m)
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
with self.assertWarns(DeprecationWarning):
self.assertEqual(msg.get_filename(), 'myfile.txt')

def test_rfc2231_single_tick_in_filename_extended(self):
Expand Down
8 changes: 2 additions & 6 deletions Lib/test/test_email/test_headerregistry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime
import textwrap
import unittest
import warnings
from email import errors
from email import policy
from email.message import Message
Expand Down Expand Up @@ -249,11 +248,8 @@ def content_type_as_value(self,
header = 'Content-Type:' + ' ' if source else ''
folded = args[3] if l>3 else header + decoded + '\n'
# Suppress deprecation warning for rfc2231_nonascii_in_charset_of_charset_parameter_value
if 'utf-8%E2%80%9D' in source:
with warnings.catch_warnings():
warnings.filterwarnings('ignore',
message='Support for non-ascii encoding names',
category=DeprecationWarning)
if 'utf-8%E2%80%9D' in source and not 'ascii' in source:
with self.assertWarns(DeprecationWarning):
h = self.make_header('Content-Type', source)
else:
h = self.make_header('Content-Type', source)
Expand Down
Loading