From 1f1d252f516968df8310835c388ad7323c513134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20D=C3=B6rwald?= Date: Fri, 4 Feb 2005 14:15:34 +0000 Subject: Add a test for UTF-16 reading where the byte sequence doesn't start with a BOM. --- Lib/test/test_codecs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index dbe9b88..5abc785 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", -- cgit v0.12