Add a test for UTF-16 reading where the byte sequence doesn't start with

a BOM.
This commit is contained in:
Walter Dörwald 2005-02-04 14:15:34 +00:00
parent 07561b3b8e
commit 1f1d252f51
1 changed files with 9 additions and 0 deletions

View File

@ -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",