44
55# local imports
66from jsonparse .parser import Parser
7- from collections import OrderedDict
7+ from collections import OrderedDict , deque
88
99# 3rd part imports
1010import pytest
@@ -15,87 +15,78 @@ class TestParser:
1515 @pytest .fixture
1616 def parser (self ):
1717
18- return Parser (stack_trace = True , queue_trace = True )
18+ return Parser (stack_trace = False , queue_trace = False )
1919
2020 @pytest .fixture
2121 def complex_json (self ):
2222
2323 return [
24- OrderedDict ({
25- "id" : "0001" ,
26- "type" : "donut" ,
27- "exists" : True ,
28- "ppu" : 0.55 ,
29- "batters" :
30- OrderedDict ({
31- "batter" :
32- [
33- OrderedDict ({"id" : "1001" , "type" : "Reg" }),
34- OrderedDict ({"id" : "1002" , "type" : "Chocolate" }),
35- OrderedDict ({"id" : "1003" , "type" : "Blueberry" }),
36- OrderedDict ({"id" : "1004" , "type" : "Devil's Food" }),
37- OrderedDict ({"start" : 5 , "end" : 8 })
38- ]
39- }),
40- "topping" :
41- [
42- OrderedDict ({"id" : "5001" , "ty" : "None" }),
43- OrderedDict ({"id" : "5002" , "type" : "Glazed" }),
44- OrderedDict ({"id" : "5003" , "type" : "Sugar" }),
45- OrderedDict ({"id" : "5004" , "type" : "Powdered Sugar" }),
46- OrderedDict ({"id" : "5005" , "type" : "Chocolate with Sprinkles" }),
47- OrderedDict ({"id" : "5006" , "type" : "Chocolate" }),
48- OrderedDict ({"id" : "5007" , "type" : "Maple" })
49- ],
50- "start" : 22 ,
51- "end" : 99
52- }),
53- OrderedDict ({
54- "id" : "0002" ,
55- "type" : "donut" ,
56- "exists" : False ,
57- "ppu" : 42 ,
58- "batters" :
59- OrderedDict ({
60- "batter" :
61- [
62- OrderedDict ({"id" : "1001" , "type" : "Rul" })
63- ]
64- }),
65- "top_stuff" :
66- [
67- OrderedDict ({"id" : "5001" , "typ" : "None" }),
68- OrderedDict ({"id" : "5002" , "type" : "Glazed" }),
69- OrderedDict ({"id" : "5003" , "type" : "Sugar" }),
70- OrderedDict ({"id" : "5004" , "type" : "Chocolate" }),
71- OrderedDict ({"id" : "5005" , "type" : "Maple" })
72- ],
73- "start" : 1 ,
74- "end" : 9
75- }),
76- OrderedDict ({
77- "id" : "0003" ,
78- "type" : "donut" ,
79- "exists" : None ,
80- "ppu" : 7 ,
81- "batters" :
82- OrderedDict ({
83- "batter" :
84- [
85- OrderedDict ({"id" : "1001" , "type" : "Lar" }),
86- OrderedDict ({"id" : "1002" , "type" : "Chocolate" })
87- ]
88- }),
89- "on_top_thing" :
90- [
91- OrderedDict ({"id" : "5001" , "type" : "None" }),
92- OrderedDict ({"id" : "5002" , "type" : "Glazed" }),
93- OrderedDict ({"id" : "5003" , "type" : "Chocolate" }),
94- OrderedDict ({"id" : "5004" , "type" : "Maple" })
95- ],
96- "start" : 4 ,
97- "end" : 7
98- })
24+ OrderedDict ([
25+ ("id" , "0001" ),
26+ ("type" , "donut" ),
27+ ("exists" , True ),
28+ ("ppu" , 0.55 ),
29+ ("batters" , OrderedDict ([
30+ ("batter" , [
31+ OrderedDict ([("id" , "1001" ), ("type" , "Reg" )]),
32+ OrderedDict ([("id" , "1002" ), ("type" , "Chocolate" )]),
33+ OrderedDict ([("id" , "1003" ), ("type" , "Blueberry" )]),
34+ OrderedDict ([("id" , "1004" ), ("type" , "Devil's Food" )]),
35+ OrderedDict ([("start" , 5 ), ("end" , 8 )])
36+ ])
37+ ])),
38+ ("topping" , [
39+ OrderedDict ([("id" , "5001" ), ("ty" , "None" )]),
40+ OrderedDict ([("id" , "5002" ), ("type" , "Glazed" )]),
41+ OrderedDict ([("id" , "5003" ), ("type" , "Sugar" )]),
42+ OrderedDict ([("id" , "5004" ), ("type" , "Powdered Sugar" )]),
43+ OrderedDict ([("id" , "5005" ), ("type" , "Chocolate with Sprinkles" )]),
44+ OrderedDict ([("id" , "5006" ), ("type" , "Chocolate" )]),
45+ OrderedDict ([("id" , "5007" ), ("type" , "Maple" )])
46+ ]),
47+ ("start" , 22 ),
48+ ("end" , 99 )
49+ ]),
50+ OrderedDict ([
51+ ("id" , "0002" ),
52+ ("type" , "donut" ),
53+ ("exists" , False ),
54+ ("ppu" , 42 ),
55+ ("batters" , OrderedDict ([
56+ ("batter" , [
57+ OrderedDict ([("id" , "1001" ), ("type" , "Rul" )])
58+ ])
59+ ])),
60+ ("top_stuff" , [
61+ OrderedDict ([("id" , "5001" ), ("typ" , "None" )]),
62+ OrderedDict ([("id" , "5002" ), ("type" , "Glazed" )]),
63+ OrderedDict ([("id" , "5003" ), ("type" , "Sugar" )]),
64+ OrderedDict ([("id" , "5004" ), ("type" , "Chocolate" )]),
65+ OrderedDict ([("id" , "5005" ), ("type" , "Maple" )])
66+ ]),
67+ ("start" , 1 ),
68+ ("end" , 9 )
69+ ]),
70+ OrderedDict ([
71+ ("id" , "0003" ),
72+ ("type" , "donut" ),
73+ ("exists" , None ),
74+ ("ppu" , 7 ),
75+ ("batters" , OrderedDict ([
76+ ("batter" , [
77+ OrderedDict ([("id" , "1001" ), ("type" , "Lar" )]),
78+ OrderedDict ([("id" , "1002" ), ("type" , "Chocolate" )])
79+ ])
80+ ])),
81+ ("on_top_thing" , [
82+ OrderedDict ([("id" , "5001" ), ("type" , "None" )]),
83+ OrderedDict ([("id" , "5002" ), ("type" , "Glazed" )]),
84+ OrderedDict ([("id" , "5003" ), ("type" , "Chocolate" )]),
85+ OrderedDict ([("id" , "5004" ), ("type" , "Maple" )])
86+ ]),
87+ ("start" , 4 ),
88+ ("end" , 7 )
89+ ])
9990 ]
10091
10192 def test_find_key (self , parser , complex_json ):
0 commit comments