Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbcae3c

Browse files
committed
Issue #15615: Add some tests for the json module's handling of invalid input data.
Patch by Kushal Das.
2 parents 35fa864 + b47ea9a commit dbcae3c

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lib/test/json_tests/test_decode.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ def test_keys_reuse(self):
5454
self.check_keys_reuse(s, self.loads)
5555
self.check_keys_reuse(s, self.json.decoder.JSONDecoder().decode)
5656

57+
def test_extra_data(self):
58+
s = '[1, 2, 3]5'
59+
msg = 'Extra data'
60+
self.assertRaisesRegexp(ValueError, msg, self.loads, s)
61+
62+
def test_invalid_escape(self):
63+
s = '["abc\\y"]'
64+
msg = 'escape'
65+
self.assertRaisesRegexp(ValueError, msg, self.loads, s)
5766

5867
class TestPyDecode(TestDecode, PyTest): pass
5968
class TestCDecode(TestDecode, CTest): pass

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Evan Dandrea
238238
Eric Daniel
239239
Scott David Daniels
240240
Ben Darnell
241+
Kushal Das
241242
Jonathan Dasteel
242243
Pierre-Yves David
243244
Xavier de Gaye

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ Documentation
5252
- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
5353
Daniel Ellis.
5454

55+
Tests
56+
-----
57+
58+
- Issue #15615: Add some tests for the json module's handling of invalid
59+
input data. Patch by Kushal Das.
5560

5661

5762
What's New in Python 3.3.0 Beta 2?

0 commit comments

Comments
 (0)