summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-02-04 14:15:34 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-02-04 14:15:34 (GMT)
commit1f1d252f516968df8310835c388ad7323c513134 (patch)
tree0f1eb39ea8ed2def0a05ee1f0f6cb77bf26b24da /Lib/test/test_codecs.py
parent07561b3b8e35553ebdbf2cab3afc52378c0e50ff (diff)
downloadcpython-1f1d252f516968df8310835c388ad7323c513134.zip
cpython-1f1d252f516968df8310835c388ad7323c513134.tar.gz
cpython-1f1d252f516968df8310835c388ad7323c513134.tar.bz2
Add a test for UTF-16 reading where the byte sequence doesn't start with
a BOM.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py9
1 files changed, 9 insertions, 0 deletions
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",