mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
gh-113149: Improve error message when JSON has trailing comma (GH-113227)
This commit is contained in:
parent
21d52995ea
commit
cfa25fe3e3
4 changed files with 28 additions and 3 deletions
|
@ -143,11 +143,11 @@ class TestFail:
|
|||
('{"spam":[}', 'Expecting value', 9),
|
||||
('[42:', "Expecting ',' delimiter", 3),
|
||||
('[42 "spam"', "Expecting ',' delimiter", 4),
|
||||
('[42,]', 'Expecting value', 4),
|
||||
('[42,]', "Illegal trailing comma before end of array", 3),
|
||||
('{"spam":[42}', "Expecting ',' delimiter", 11),
|
||||
('["]', 'Unterminated string starting at', 1),
|
||||
('["spam":', "Expecting ',' delimiter", 7),
|
||||
('["spam",]', 'Expecting value', 8),
|
||||
('["spam",]', "Illegal trailing comma before end of array", 7),
|
||||
('{:', 'Expecting property name enclosed in double quotes', 1),
|
||||
('{,', 'Expecting property name enclosed in double quotes', 1),
|
||||
('{42', 'Expecting property name enclosed in double quotes', 1),
|
||||
|
@ -159,7 +159,9 @@ class TestFail:
|
|||
('[{"spam":]', 'Expecting value', 9),
|
||||
('{"spam":42 "ham"', "Expecting ',' delimiter", 11),
|
||||
('[{"spam":42]', "Expecting ',' delimiter", 11),
|
||||
('{"spam":42,}', 'Expecting property name enclosed in double quotes', 11),
|
||||
('{"spam":42,}', "Illegal trailing comma before end of object", 10),
|
||||
('{"spam":42 , }', "Illegal trailing comma before end of object", 11),
|
||||
('[123 , ]', "Illegal trailing comma before end of array", 6),
|
||||
]
|
||||
for data, msg, idx in test_cases:
|
||||
with self.assertRaises(self.JSONDecodeError) as cm:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue