Skip to content

Commit 52e590c

Browse files
committed
resort import; restructure testcase
1 parent 77ea798 commit 52e590c

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

Lib/email/contentmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import email.charset
33
import email.message
44
import email.errors
5-
from email import quoprimime
65
import sys
6+
from email import quoprimime
77

88
class ContentManager:
99

Lib/test/test_email/test_message.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,24 +1005,29 @@ def test_folding_with_long_nospace_http_policy_1(self):
10051005
self.assertEqual(parsed_msg['Message-ID'], m['Message-ID'])
10061006

10071007
def test_no_wrapping_max_line_length(self):
1008-
def do_test_no_wrapping_max_line_length(n):
1009-
pol = policy.default.clone(max_line_length=n)
1010-
subj = "S" * 100
1011-
body = "B" * 100
1012-
msg = EmailMessage(policy=pol)
1013-
msg["From"] = "[email protected]"
1014-
msg["To"] = "[email protected]"
1015-
msg["Subject"] = subj
1016-
msg.set_content(body)
1017-
1018-
raw = msg.as_bytes()
1019-
self.assertNotIn(b"\r\n ", raw, "Found fold indicator; wrapping not disabled")
1020-
1021-
parsed = message_from_bytes(msg.as_bytes(), policy=policy.default)
1022-
self.assertEqual(parsed["Subject"], subj)
1023-
self.assertEqual(parsed.get_body().get_content().rstrip('\n'), body)
1024-
do_test_no_wrapping_max_line_length(None)
1025-
do_test_no_wrapping_max_line_length(0)
1008+
# Test that falsey 'max_line_length' are converted to sys.maxsize.
1009+
for n in [0, None]:
1010+
with self.subTest(max_line_length=n):
1011+
self.do_test_no_wrapping_max_line_length(n)
1012+
1013+
def do_test_no_wrapping_max_line_length(self, n):
1014+
pol = policy.default.clone(max_line_length=n)
1015+
subj = "S" * 100
1016+
body = "B" * 100
1017+
msg = EmailMessage(policy=pol)
1018+
msg["From"] = "[email protected]"
1019+
msg["To"] = "[email protected]"
1020+
msg["Subject"] = subj
1021+
msg.set_content(body)
1022+
1023+
raw = msg.as_bytes()
1024+
self.assertNotIn(b"\r\n ", raw,
1025+
"Found fold indicator; wrapping not disabled")
1026+
1027+
parsed = message_from_bytes(msg.as_bytes(), policy=policy.default)
1028+
self.assertEqual(parsed["Subject"], subj)
1029+
parsed_body = parsed.get_body().get_content().rstrip('\n')
1030+
self.assertEqual(parsed_body, body)
10261031

10271032
def test_invalid_header_names(self):
10281033
invalid_headers = [

0 commit comments

Comments
 (0)