mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
testing control chars and non-dict root objects
This commit is contained in:
parent
b84330d368
commit
48ecaccf9e
1 changed files with 16 additions and 0 deletions
|
@ -164,6 +164,22 @@ class TestPlistlib(unittest.TestCase):
|
|||
pl2 = plistlib.readPlist(StringIO(f.getvalue()))
|
||||
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)
|
||||
|
||||
def test_nondictroot(self):
|
||||
test1 = "abc"
|
||||
test2 = [1, 2, 3, "abc"]
|
||||
result1 = plistlib.readPlistFromString(plistlib.writePlistToString(test1))
|
||||
result2 = plistlib.readPlistFromString(plistlib.writePlistToString(test2))
|
||||
self.assertEqual(test1, result1)
|
||||
self.assertEqual(test2, result2)
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue