From: Antoine Pitrou Date: Sat, 18 Aug 2012 18:51:05 +0000 (+0200) Subject: Issue #15615: Add some tests for the json module's handling of invalid input data. X-Git-Tag: v2.7.5~109^2~367 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e3a4c80585ce993dc274b6cea31f283948e1c44;p=python Issue #15615: Add some tests for the json module's handling of invalid input data. Patch by Kushal Das. --- diff --git a/Lib/json/tests/test_decode.py b/Lib/json/tests/test_decode.py index aa8bbe9b54..478a16ba0f 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 diff --git a/Misc/ACKS b/Misc/ACKS index 1fad05b7eb..f13c7b05e0 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -194,6 +194,7 @@ Evan Dandrea Eric Daniel Scott David Daniels Ben Darnell +Kushal Das Jonathan Dasteel John DeGood Ned Deily diff --git a/Misc/NEWS b/Misc/NEWS index 190f8f4e36..34143bfe97 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -335,6 +335,9 @@ Library Tests ----- +- Issue #15615: Add some tests for the json module's handling of invalid + input data. Patch by Kushal Das. + - Issue #15496: Add directory removal helpers for tests on Windows. Patch by Jeremy Kloth.