[Python-checkins] python/dist/src/Lib/test test_plistlib.py, 1.6, 1.7

jvr at users.sourceforge.net jvr at users.sourceforge.net
Fri Nov 12 10:36:17 CET 2004


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

Modified Files:
	test_plistlib.py 
Log Message:
On second thought: "Errors should never pass silently", so barf when a
string contains control chars that are illegal for XML


Index: test_plistlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_plistlib.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_plistlib.py	12 Nov 2004 08:34:32 -0000	1.6
+++ test_plistlib.py	12 Nov 2004 09:36:12 -0000	1.7
@@ -165,13 +165,16 @@
         self.assertEqual(dict(pl), dict(pl2))
 
     def test_controlcharacters(self):
-        # chars in the range 0..31 are replaced by '?', except for
-        # \r, \n and \t since they aren't legal XML characters
-        testString = "".join([chr(i) for i in range(32)])
-        expectedResult = '?????????\t\n??\n??????????????????'
-        xml = plistlib.writePlistToString(testString)
-        result = plistlib.readPlistFromString(xml)
-        self.assertEqual(result, expectedResult)
+        for i in range(128):
+            c = chr(i)
+            testString = "string containing %s" % c
+            if i >= 32 or c in "\r\n\t":
+                # \r, \n and \t are the only legal control chars in XML
+                plistlib.writePlistToString(testString)
+            else:
+                self.assertRaises(ValueError,
+                                  plistlib.writePlistToString,
+                                  testString)
 
     def test_nondictroot(self):
         test1 = "abc"



More information about the Python-checkins mailing list