Skip to content

Commit 8b30b4e

Browse files
committed
Change test to consider nulls in mult lvls
So rather than just testing the inner most json, test to see it doesn't except null at multiple levels of the json
1 parent b24898b commit 8b30b4e

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

pandas/tests/io/json/test_normalize.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -376,26 +376,31 @@ def test_nonetype_dropping(self):
376376

377377
assert result == expected
378378

379-
def test_nonetype_inner_most_level(self):
380-
# GH21158: If the inner most json has a key with a null value
379+
def test_nonetype_multiple_levels(self):
380+
# GH21158: If inner level json has a key with a null value
381381
# make sure it doesnt do a new_d.pop twice and except
382382
data = {
383-
"subject": {
384-
"pairs": {
385-
"A1-A2": {
386-
"atlases": {
387-
"avg.corrected": {
388-
"region": None,
389-
"x": 49.151580810546875,
390-
"y": -33.148521423339844,
391-
"z": 27.572303771972656}}}
392-
}
383+
"id": None,
384+
"location": {
385+
"id": None,
386+
"country": {
387+
"id": None,
388+
"state": {
389+
"id": None,
390+
"town.info": {
391+
"region": None,
392+
"x": 49.151580810546875,
393+
"y": -33.148521423339844,
394+
"z": 27.572303771972656}}}
393395
}
394396
}
395397
result = nested_to_record(data)
396398
expected = {
397-
'subject.pairs.A1-A2.atlases.avg.corrected.region': None,
398-
'subject.pairs.A1-A2.atlases.avg.corrected.x': 49.151580810546875,
399-
'subject.pairs.A1-A2.atlases.avg.corrected.y': -33.148521423339844,
400-
'subject.pairs.A1-A2.atlases.avg.corrected.z': 27.572303771972656}
399+
'location.id': None,
400+
'location.country.id': None,
401+
'location.country.state.id': None,
402+
'location.country.state.town.info.region': None,
403+
'location.country.state.town.info.x': 49.151580810546875,
404+
'location.country.state.town.info.y': -33.148521423339844,
405+
'location.country.state.town.info.z': 27.572303771972656}
401406
assert result == expected

0 commit comments

Comments
 (0)