Skip to content

Commit e4036f8

Browse files
Convert to asserts
1 parent 16697dc commit e4036f8

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Lib/test/test_email/test_email.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5717,9 +5717,7 @@ def test_rfc2231_bad_character_in_encoding(self):
57175717
57185718
"""
57195719
msg = email.message_from_string(m)
5720-
import warnings
5721-
with warnings.catch_warnings():
5722-
warnings.simplefilter("ignore", DeprecationWarning)
5720+
with self.assertWarns(DeprecationWarning):
57235721
self.assertEqual(msg.get_filename(), 'myfile.txt')
57245722

57255723
def test_rfc2231_single_tick_in_filename_extended(self):

Lib/test/test_email/test_headerregistry.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import datetime
22
import textwrap
33
import unittest
4-
import warnings
54
from email import errors
65
from email import policy
76
from email.message import Message
@@ -249,11 +248,8 @@ def content_type_as_value(self,
249248
header = 'Content-Type:' + ' ' if source else ''
250249
folded = args[3] if l>3 else header + decoded + '\n'
251250
# Suppress deprecation warning for rfc2231_nonascii_in_charset_of_charset_parameter_value
252-
if 'utf-8%E2%80%9D' in source:
253-
with warnings.catch_warnings():
254-
warnings.filterwarnings('ignore',
255-
message='Support for non-ascii encoding names',
256-
category=DeprecationWarning)
251+
if 'utf-8%E2%80%9D' in source and not 'ascii' in source:
252+
with self.assertWarns(DeprecationWarning):
257253
h = self.make_header('Content-Type', source)
258254
else:
259255
h = self.make_header('Content-Type', source)

0 commit comments

Comments
 (0)