Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(165856)

Unified Diff: Lib/test/test_json/test_decode.py

Issue 19361: Specialize exceptions thrown by JSON parser
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_json/__init__.py ('k') | Lib/test/test_json/test_fail.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_json/test_decode.py Sun Nov 30 20:39:04 2014 +0200
+++ b/Lib/test/test_json/test_decode.py Mon Dec 01 00:17:14 2014 +0200
@@ -63,12 +63,12 @@ class TestDecode:
def test_extra_data(self):
s = '[1, 2, 3]5'
msg = 'Extra data'
- self.assertRaisesRegex(ValueError, msg, self.loads, s)
+ self.assertRaisesRegex(self.JSONDecodeError, msg, self.loads, s)
def test_invalid_escape(self):
s = '["abc\\y"]'
msg = 'escape'
- self.assertRaisesRegex(ValueError, msg, self.loads, s)
+ self.assertRaisesRegex(self.JSONDecodeError, msg, self.loads, s)
def test_invalid_input_type(self):
msg = 'the JSON object must be str'
@@ -80,10 +80,10 @@ class TestDecode:
def test_string_with_utf8_bom(self):
# see #18958
bom_json = "[1,2,3]".encode('utf-8-sig').decode('utf-8')
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(self.JSONDecodeError) as cm:
self.loads(bom_json)
self.assertIn('BOM', str(cm.exception))
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(self.JSONDecodeError) as cm:
self.json.load(StringIO(bom_json))
self.assertIn('BOM', str(cm.exception))
# make sure that the BOM is not detected in the middle of a string
« no previous file with comments | « Lib/test/test_json/__init__.py ('k') | Lib/test/test_json/test_fail.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+