Skip to content

Commit

Permalink
pythongh-127794: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srinivasreddy committed Dec 13, 2024
1 parent 026f35b commit 8f6f6c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/email/_policybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def validate_header(name):
raise ValueError(f"Invalid header field name {name!r}")
# Only allow printable ASCII characters
if any(ord(c) < 33 or ord(c) > 126 for c in name):
raise ValueError(f"Header field name {name!r} contains invalid characters")
raise ValueError(f"Invalid header field name {name!r}")

def _append_doc(doc, added_doc):
doc = doc.rsplit('\n', 1)[0]
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def test_invalid_headers(self):
for name, value in invalid_headers:
with self.assertRaises(ValueError) as cm:
Message().add_header(name, value)
self.assertIn("Invalid header field name", str(cm.exception))
self.assertIn(f"Invalid header field name {name!r}", str(cm.exception))

invalid_headers = [
('Header\x7F', 'Non-ASCII character'),
Expand All @@ -749,7 +749,7 @@ def test_invalid_headers(self):
for name, value in invalid_headers:
with self.assertRaises(ValueError) as cm:
Message().add_header(name, value)
self.assertIn(f"Header field name {name!r} contains invalid characters", str(cm.exception))
self.assertIn(f"Invalid header field name {name!r}", str(cm.exception))

def test_binary_quopri_payload(self):
for charset in ('latin-1', 'ascii'):
Expand Down

0 comments on commit 8f6f6c3

Please sign in to comment.