diff options
author | Jon Janzen <jjjonjanzen@gmail.com> | 2019-11-02 14:48:22 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-11-02 14:48:22 (GMT) |
commit | fe934e1d03bca6ca6dd1bf87fce1695eeac984ce (patch) | |
tree | 770156238fb284d047ee4f241c590a04699ef807 /Lib | |
parent | 952899704800a5aa438e84d50f0b6fc498c72e89 (diff) | |
download | cpython-fe934e1d03bca6ca6dd1bf87fce1695eeac984ce.zip cpython-fe934e1d03bca6ca6dd1bf87fce1695eeac984ce.tar.gz cpython-fe934e1d03bca6ca6dd1bf87fce1695eeac984ce.tar.bz2 |
[3.8] Slightly improve plistlib test coverage. (GH-17025) (GH-17028)
* Add missing test class (mistake in GH-4455)
* Increase coverage with 4 more test cases
* Rename neg_uid to huge_uid in test_modified_uid_huge
* Replace test_main() with unittest.main()
* Update plistlib docs.
(cherry picked from commit d0d9f7cfa36bafa4e1d9e73eb08835180d376df1)
Co-authored-by: Jon Janzen <jjjonjanzen@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_plistlib.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index 5c2d026..0d887e2 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -505,6 +505,26 @@ class TestPlistlib(unittest.TestCase): pl2 = plistlib.loads(data) self.assertEqual(dict(pl), dict(pl2)) + def test_dump_invalid_format(self): + with self.assertRaises(ValueError): + plistlib.dumps({}, fmt="blah") + + def test_load_invalid_file(self): + with self.assertRaises(plistlib.InvalidFileException): + plistlib.loads(b"these are not plist file contents") + + def test_modified_uid_negative(self): + neg_uid = UID(1) + neg_uid.data = -1 # dodge the negative check in the constructor + with self.assertRaises(ValueError): + plistlib.dumps(neg_uid, fmt=plistlib.FMT_BINARY) + + def test_modified_uid_huge(self): + huge_uid = UID(1) + huge_uid.data = 2 ** 64 # dodge the size check in the constructor + with self.assertRaises(OverflowError): + plistlib.dumps(huge_uid, fmt=plistlib.FMT_BINARY) + class TestBinaryPlistlib(unittest.TestCase): @@ -748,9 +768,5 @@ class MiscTestCase(unittest.TestCase): support.check__all__(self, plistlib, blacklist=blacklist) -def test_main(): - support.run_unittest(TestPlistlib, TestPlistlibDeprecated, TestKeyedArchive, MiscTestCase) - - if __name__ == '__main__': - test_main() + unittest.main() |