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

Skip to content

Commit b47ea9a

Browse files
committed
Issue #15615: Add some tests for the json module's handling of invalid input data.
Patch by Kushal Das.
1 parent 05d79e9 commit b47ea9a

3 files changed

Lines changed: 13 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
@@ -218,6 +218,7 @@ Evan Dandrea
218218
Eric Daniel
219219
Scott David Daniels
220220
Ben Darnell
221+
Kushal Das
221222
Jonathan Dasteel
222223
John DeGood
223224
Ned Deily

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ Extension Modules
425425
Tests
426426
-----
427427

428+
- Issue #15615: Add some tests for the json module's handling of invalid
429+
input data. Patch by Kushal Das.
430+
428431
- Issue #15496: Add directory removal helpers for tests on Windows.
429432
Patch by Jeremy Kloth.
430433

0 commit comments

Comments
 (0)