[Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.18, 1.19

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Fri Feb 4 15:15:37 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27454/Lib/test

Modified Files:
	test_codecs.py 
Log Message:
Add a test for UTF-16 reading where the byte sequence doesn't start with
a BOM.


Index: test_codecs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test_codecs.py	10 Jan 2005 12:01:39 -0000	1.18
+++ test_codecs.py	4 Feb 2005 14:15:34 -0000	1.19
@@ -159,6 +159,15 @@
         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",



More information about the Python-checkins mailing list