summaryrefslogtreecommitdiffstats
path: root/Lib/json
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:51:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-18 18:51:05 (GMT)
commit0e3a4c80585ce993dc274b6cea31f283948e1c44 (patch)
tree5e79bcf52fe4d3cb2aa3da83bbc757c305ae23ca /Lib/json
parent2de4be2efdbed0527a70ed9c2c851c52683a689d (diff)
downloadcpython-0e3a4c80585ce993dc274b6cea31f283948e1c44.zip
cpython-0e3a4c80585ce993dc274b6cea31f283948e1c44.tar.gz
cpython-0e3a4c80585ce993dc274b6cea31f283948e1c44.tar.bz2
Issue #15615: Add some tests for the json module's handling of invalid input data.
Patch by Kushal Das.
Diffstat (limited to 'Lib/json')
-rw-r--r--Lib/json/tests/test_decode.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/json/tests/test_decode.py b/Lib/json/tests/test_decode.py
index aa8bbe9..478a16b 100644
--- a/Lib/json/tests/test_decode.py
+++ b/Lib/json/tests/test_decode.py
@@ -45,6 +45,15 @@ class TestDecode(object):
object_hook=lambda x: None),
OrderedDict(p))
+ def test_extra_data(self):
+ s = '[1, 2, 3]5'
+ msg = 'Extra data'
+ self.assertRaisesRegexp(ValueError, msg, self.loads, s)
+
+ def test_invalid_escape(self):
+ s = '["abc\\y"]'
+ msg = 'escape'
+ self.assertRaisesRegexp(ValueError, msg, self.loads, s)
class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass