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

Side by Side Diff: Lib/test/test_json/test_scanstring.py

Issue 19361: Specialize exceptions thrown by JSON parser
Patch Set: Created 4 years, 7 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Lib/test/test_json/test_fail.py ('k') | Modules/_json.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import sys 1 import sys
2 from test.test_json import PyTest, CTest 2 from test.test_json import PyTest, CTest
3 3
4 4
5 class TestScanstring: 5 class TestScanstring:
6 def test_scanstring(self): 6 def test_scanstring(self):
7 scanstring = self.json.decoder.scanstring 7 scanstring = self.json.decoder.scanstring
8 self.assertEqual( 8 self.assertEqual(
9 scanstring('"z\U0001d120x"', 1, True), 9 scanstring('"z\U0001d120x"', 1, True),
10 ('z\U0001d120x', 5)) 10 ('z\U0001d120x', 5))
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 '"\\ud834\\udd"', 122 '"\\ud834\\udd"',
123 '"\\ud834\\udd2"', 123 '"\\ud834\\udd2"',
124 '"\\ud834\\uzdd2"', 124 '"\\ud834\\uzdd2"',
125 '"\\ud834\\udzd2"', 125 '"\\ud834\\udzd2"',
126 '"\\ud834\\uddz2"', 126 '"\\ud834\\uddz2"',
127 '"\\ud834\\udd2z"', 127 '"\\ud834\\udd2z"',
128 '"\\ud834\\u0x20"', 128 '"\\ud834\\u0x20"',
129 '"\\ud834\\u0X20"', 129 '"\\ud834\\u0X20"',
130 ] 130 ]
131 for s in bad_escapes: 131 for s in bad_escapes:
132 with self.assertRaises(ValueError, msg=s): 132 with self.assertRaises(self.JSONDecodeError, msg=s):
133 scanstring(s, 1, True) 133 scanstring(s, 1, True)
134 134
135 def test_overflow(self): 135 def test_overflow(self):
136 with self.assertRaises(OverflowError): 136 with self.assertRaises(OverflowError):
137 self.json.decoder.scanstring(b"xxx", sys.maxsize+1) 137 self.json.decoder.scanstring(b"xxx", sys.maxsize+1)
138 138
139 139
140 class TestPyScanstring(TestScanstring, PyTest): pass 140 class TestPyScanstring(TestScanstring, PyTest): pass
141 class TestCScanstring(TestScanstring, CTest): pass 141 class TestCScanstring(TestScanstring, CTest): pass
OLDNEW
« no previous file with comments | « Lib/test/test_json/test_fail.py ('k') | Modules/_json.c » ('j') | no next file with comments »

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