Commit 0e3a4c80 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #15615: Add some tests for the json module's handling of invalid input data.

Patch by Kushal Das.
parent 2de4be2e
...@@ -45,6 +45,15 @@ class TestDecode(object): ...@@ -45,6 +45,15 @@ class TestDecode(object):
object_hook=lambda x: None), object_hook=lambda x: None),
OrderedDict(p)) 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 TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass class TestCDecode(TestDecode, CTest): pass
...@@ -194,6 +194,7 @@ Evan Dandrea ...@@ -194,6 +194,7 @@ Evan Dandrea
Eric Daniel Eric Daniel
Scott David Daniels Scott David Daniels
Ben Darnell Ben Darnell
Kushal Das
Jonathan Dasteel Jonathan Dasteel
John DeGood John DeGood
Ned Deily Ned Deily
......
...@@ -335,6 +335,9 @@ Library ...@@ -335,6 +335,9 @@ Library
Tests 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. - Issue #15496: Add directory removal helpers for tests on Windows.
Patch by Jeremy Kloth. Patch by Jeremy Kloth.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment