Skip to content

Commit 55e00ae

Browse files
committed
Fix test logic and comments per review
1 parent 7d63071 commit 55e00ae

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Lib/test/test_email/test__header_value_parser.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,14 +3257,11 @@ def test_long_filename_attachment(self):
32573257

32583258
def test_fold_unfoldable_element_stealing_whitespace(self):
32593259
# gh-142006: When an element is too long to fit on the current line
3260-
# the previous line's trailing whitespace
3260+
# the previous line's trailing whitespace should not trigger a double newline.
32613261
policy = self.policy.clone(max_line_length=10)
3262-
3263-
# "a," fits. The space after it should wrap to the next line.
3264-
# The "long" part (20 chars) forces the wrap because 20 > 10.
3265-
text = "a, " + ("b" * 20)
3266-
expected = "a,\n " + ("b" * 20) + "\n"
3267-
3262+
# The non-whitespace text needs to exactly fill the max_line_length (10).
3263+
text = ("a" * 9) + ", " + ("b" * 20)
3264+
expected = ("a" * 9) + ",\n " + ("b" * 20) + "\n"
32683265
token = parser.get_address_list(text)[0]
32693266
self._test(token, expected, policy=policy)
32703267

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix :exc:`email.errors.HeaderWriteError` in :mod:`email.policy.default` which incorrectly added double newlines when folding lines containing unfoldable syntactic elements wider than max_line_len.
1+
Fix a bug in the :mod:`email.policy.default` folding algorithm which incorrectly resulted in a doubled newline when a line ending at exactly max_line_length was followed by an unfoldable token.

0 commit comments

Comments
 (0)