]> granicus.if.org Git - python/commitdiff
test_bad_8bit_header(): Tests for optional argument `errors'. See SF
authorBarry Warsaw <barry@python.org>
Mon, 30 Dec 2002 19:14:38 +0000 (19:14 +0000)
committerBarry Warsaw <barry@python.org>
Mon, 30 Dec 2002 19:14:38 +0000 (19:14 +0000)
bug #648119.

Lib/email/test/test_email.py

index 7c79739bd6375c7a326f69ff16be8754f3c6c56b..1c77819b4bb5f60130cc552a110e2c6d8a742ed3 100644 (file)
@@ -2307,6 +2307,17 @@ A very long line that must get split to something other than at the
         h = Header(u'\u83ca\u5730\u6642\u592b', 'utf-8')
         eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=')
 
+    def test_bad_8bit_header(self):
+        raises = self.assertRaises
+        eq = self.assertEqual
+        x = 'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
+        raises(UnicodeError, Header, x)
+        h = Header()
+        raises(UnicodeError, h.append, x)
+        eq(str(Header(x, errors='replace')), x)
+        h.append(x, errors='replace')
+        eq(str(h), x)
+
 
 \f
 # Test RFC 2231 header parameters (en/de)coding