summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2004-11-12 09:36:12 (GMT)
committerJust van Rossum <just@letterror.com>2004-11-12 09:36:12 (GMT)
commit2dae7646c30fcb347c093632a4df18292e246a1a (patch)
treeafb759bbc4f8f928ea8c2873ea9f50d6c94f5981 /Lib/test
parent48ecaccf9e2abd230b5745edc829118a1c526b64 (diff)
downloadcpython-2dae7646c30fcb347c093632a4df18292e246a1a.zip
cpython-2dae7646c30fcb347c093632a4df18292e246a1a.tar.gz
cpython-2dae7646c30fcb347c093632a4df18292e246a1a.tar.bz2
On second thought: "Errors should never pass silently", so barf when a
string contains control chars that are illegal for XML
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_plistlib.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index bf745d3..8e8d3e3 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -165,13 +165,16 @@ class TestPlistlib(unittest.TestCase):
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"