77from dirty_equals import IsFloatNan
88
99
10- def test_python_parse_numeric ():
10+ def test_parse_numeric ():
1111 parsed = jiter .from_json (
1212 b' { "int": 1, "bigint": 123456789012345678901234567890, "float": 1.2} '
1313 )
1414 assert parsed == {"int" : 1 , "bigint" : 123456789012345678901234567890 , "float" : 1.2 }
1515
1616
17- def test_python_parse_other_cached ():
17+ def test_parse_other_cached ():
1818 parsed = jiter .from_json (
1919 b'["string", true, false, null, NaN, Infinity, -Infinity]' ,
2020 allow_inf_nan = True ,
@@ -23,27 +23,34 @@ def test_python_parse_other_cached():
2323 assert parsed == ["string" , True , False , None , IsFloatNan (), inf , - inf ]
2424
2525
26- def test_python_parse_other_no_cache ():
26+ def test_parse_other_no_cache ():
2727 parsed = jiter .from_json (
2828 b'["string", true, false, null]' ,
2929 cache_mode = False ,
3030 )
3131 assert parsed == ["string" , True , False , None ]
3232
3333
34- def test_python_disallow_nan ():
35- with pytest .raises (ValueError , match = "expected value at line 1 column 2" ):
34+ def test_disallow_nan ():
35+ with pytest .raises (jiter . JsonParseError , match = "expected value at line 1 column 2" ):
3636 jiter .from_json (b"[NaN]" , allow_inf_nan = False )
3737
3838
3939def test_error ():
40- with pytest .raises (ValueError , match = "EOF while parsing a list at line 1 column 9" ):
40+ with pytest .raises (jiter . JsonParseError , match = "EOF while parsing a list at line 1 column 9" ) as exc_info :
4141 jiter .from_json (b'["string"' )
4242
43+ assert exc_info .value .kind () == 'EofWhileParsingList'
44+ assert exc_info .value .description () == 'EOF while parsing a list'
45+ assert exc_info .value .index () == 9
46+ assert exc_info .value .line () == 1
47+ assert exc_info .value .column () == 9
48+ assert repr (exc_info .value ) == 'JsonParseError("EOF while parsing a list at line 1 column 9")'
49+
4350
4451def test_recursion_limit ():
4552 with pytest .raises (
46- ValueError , match = "recursion limit exceeded at line 1 column 202"
53+ jiter . JsonParseError , match = "recursion limit exceeded at line 1 column 202"
4754 ):
4855 jiter .from_json (b"[" * 10_000 )
4956
@@ -150,21 +157,21 @@ def test_partial_nested():
150157 assert isinstance (parsed , dict )
151158
152159
153- def test_python_cache_usage_all ():
160+ def test_cache_usage_all ():
154161 jiter .cache_clear ()
155162 parsed = jiter .from_json (b'{"foo": "bar", "spam": 3}' , cache_mode = "all" )
156163 assert parsed == {"foo" : "bar" , "spam" : 3 }
157164 assert jiter .cache_usage () == 3
158165
159166
160- def test_python_cache_usage_keys ():
167+ def test_cache_usage_keys ():
161168 jiter .cache_clear ()
162169 parsed = jiter .from_json (b'{"foo": "bar", "spam": 3}' , cache_mode = "keys" )
163170 assert parsed == {"foo" : "bar" , "spam" : 3 }
164171 assert jiter .cache_usage () == 2
165172
166173
167- def test_python_cache_usage_none ():
174+ def test_cache_usage_none ():
168175 jiter .cache_clear ()
169176 parsed = jiter .from_json (
170177 b'{"foo": "bar", "spam": 3}' ,
0 commit comments