summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_json/test_fail.py
diff options
context:
space:
mode:
authorCarson Radtke <carsonRadtke@users.noreply.github.com>2023-12-17 18:52:26 (GMT)
committerGitHub <noreply@github.com>2023-12-17 18:52:26 (GMT)
commitcfa25fe3e39e09612a6ba8409c46cf35a091de3c (patch)
tree2cf2db21aa5e11b36fa04b5d93b5aa22ac357bd7 /Lib/test/test_json/test_fail.py
parent21d52995ea490328edf9be3ba072821cd445dd30 (diff)
downloadcpython-cfa25fe3e39e09612a6ba8409c46cf35a091de3c.zip
cpython-cfa25fe3e39e09612a6ba8409c46cf35a091de3c.tar.gz
cpython-cfa25fe3e39e09612a6ba8409c46cf35a091de3c.tar.bz2
gh-113149: Improve error message when JSON has trailing comma (GH-113227)
Diffstat (limited to 'Lib/test/test_json/test_fail.py')
-rw-r--r--Lib/test/test_json/test_fail.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_json/test_fail.py b/Lib/test/test_json/test_fail.py
index efc982e..d6bce60 100644
--- a/Lib/test/test_json/test_fail.py
+++ b/Lib/test/test_json/test_fail.py
@@ -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: