]> granicus.if.org Git - python/commitdiff
Issue #15615: Add some tests for the json module's handling of invalid input data.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 18 Aug 2012 18:51:05 +0000 (20:51 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 18 Aug 2012 18:51:05 +0000 (20:51 +0200)
Patch by Kushal Das.

Lib/json/tests/test_decode.py
Misc/ACKS
Misc/NEWS

index aa8bbe9b540d07bcc4685a9d5627eb50980bd0a8..478a16ba0fda5c0bebaa2737182556dc3261c230 100644 (file)
@@ -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
index 1fad05b7ebfb32b9e799f13f29bdea9a29044cef..f13c7b05e08334fb4191e1c1a1c57e51b0cf9409 100644 (file)
--- 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
index 190f8f4e3693bfe301e8ad5aba2b9e5ca4c2929c..34143bfe9742168e9de979c4cb74ab5649a1bdce 100644 (file)
--- 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.