Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 10ee7a7

Browse files
committed
test_bad_8bit_header(): Tests for optional argument `errors'. See SF
bug #648119.
1 parent f4fdff7 commit 10ee7a7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/email/test/test_email.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,17 @@ def test_utf8_shortest(self):
23072307
h = Header(u'\u83ca\u5730\u6642\u592b', 'utf-8')
23082308
eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=')
23092309

2310+
def test_bad_8bit_header(self):
2311+
raises = self.assertRaises
2312+
eq = self.assertEqual
2313+
x = 'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
2314+
raises(UnicodeError, Header, x)
2315+
h = Header()
2316+
raises(UnicodeError, h.append, x)
2317+
eq(str(Header(x, errors='replace')), x)
2318+
h.append(x, errors='replace')
2319+
eq(str(h), x)
2320+
23102321

23112322

23122323
# Test RFC 2231 header parameters (en/de)coding

0 commit comments

Comments
 (0)