From: Walter Dörwald Date: Fri, 4 Feb 2005 14:15:34 +0000 (+0000) Subject: Add a test for UTF-16 reading where the byte sequence doesn't start with X-Git-Tag: v2.5a0~2060 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f1d252f516968df8310835c388ad7323c513134;p=thirdparty%2FPython%2Fcpython.git Add a test for UTF-16 reading where the byte sequence doesn't start with a BOM. --- diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index dbe9b88dbd8a..5abc78565740 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -159,6 +159,15 @@ class UTF16Test(ReadTest): f = reader(s) self.assertEquals(f.read(), u"spamspam") + def test_badbom(self): + s = StringIO.StringIO("\xff\xff") + f = codecs.getwriter(self.encoding)(s) + self.assertRaises(UnicodeError, f.read) + + s = StringIO.StringIO("\xff\xff\xff\xff") + f = codecs.getwriter(self.encoding)(s) + self.assertRaises(UnicodeError, f.read) + def test_partial(self): self.check_partial( u"\x00\xff\u0100\uffff",