@@ -162,21 +162,27 @@ def test_empty_array(self):
162
162
tm .assert_frame_equal (result , expected )
163
163
164
164
@pytest .mark .parametrize (
165
- "data, record_path, exception_type" ,
165
+ "data, record_path, exception_type, expected " ,
166
166
[
167
- ([{"a" : 0 }, {"a" : 1 }], None , None ),
168
- ({"a" : [{"a" : 0 }, {"a" : 1 }]}, "a" , None ),
169
- ('{"a": [{"a": 0}, {"a": 1}]}' , None , None ),
170
- (None , None , NotImplementedError ),
167
+ # List of dicts
168
+ ([{"a" : 0 }, {"a" : 1 }], None , None , DataFrame ([0 , 1 ], columns = ["a" ])),
169
+
170
+ # Dict with array
171
+ ({"a" : [{"a" : 0 }, {"a" : 1 }]}, "a" , None , DataFrame ([0 , 1 ], columns = ["a" ])),
172
+
173
+ # JSON string of array
174
+ ('[{"a": 0}, {"a": 1}]' , None , None , DataFrame ([0 , 1 ], columns = ["a" ])),
175
+
176
+ # None input
177
+ (None , None , NotImplementedError , None ),
171
178
],
172
179
)
173
- def test_accepted_input (self , data , record_path , exception_type ):
180
+ def test_accepted_input (self , data , record_path , exception_type , expected ):
174
181
if exception_type is not None :
175
182
with pytest .raises (exception_type , match = "" ):
176
183
json_normalize (data , record_path = record_path )
177
184
else :
178
185
result = json_normalize (data , record_path = record_path )
179
- expected = DataFrame ([0 , 1 ], columns = ["a" ])
180
186
tm .assert_frame_equal (result , expected )
181
187
182
188
def test_simple_normalize_with_separator (self , deep_nested ):
0 commit comments