diff options
Diffstat (limited to 'tests/test_library.py')
| -rw-r--r-- | tests/test_library.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_library.py b/tests/test_library.py index 84fa3cc..7e06ca4 100644 --- a/tests/test_library.py +++ b/tests/test_library.py @@ -89,3 +89,19 @@ class LibraryTest(unittest.TestCase): p = Path(self.tmp.name) / "x.duf" p.write_text(json.dumps({"x": 1})) self.assertEqual(read_dson(p), {"x": 1}) + + +class ReadDsonCrashTest(unittest.TestCase): + def read(self, data): + with tempfile.TemporaryDirectory() as d: + p = Path(d) / "x.dsf" + p.write_bytes(data) + read_dson(p) + + def test_corrupt_gzip_is_error(self): + with self.assertRaises(Error): + self.read(b"\x1f\x8b\x08\x00" + b"\xff" * 20) + + def test_deep_nesting_is_error(self): + with self.assertRaises(Error): + self.read(b"[" * 200000) |
