Skip to content

Commit 16697dc

Browse files
Fix second warning
1 parent 9d6f06e commit 16697dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/test_email/test_headerregistry.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
22
import textwrap
33
import unittest
4+
import warnings
45
from email import errors
56
from email import policy
67
from email.message import Message
@@ -247,7 +248,15 @@ def content_type_as_value(self,
247248
decoded = args[2] if l>2 and args[2] is not DITTO else source
248249
header = 'Content-Type:' + ' ' if source else ''
249250
folded = args[3] if l>3 else header + decoded + '\n'
250-
h = self.make_header('Content-Type', source)
251+
# 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)
257+
h = self.make_header('Content-Type', source)
258+
else:
259+
h = self.make_header('Content-Type', source)
251260
self.assertEqual(h.content_type, content_type)
252261
self.assertEqual(h.maintype, maintype)
253262
self.assertEqual(h.subtype, subtype)

0 commit comments

Comments
 (0)