File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,27 @@ def test_set_list_with_dict_int_ambiguity():
5252 assert d == expected
5353
5454
55+ def test_int_segment_list_type_check ():
56+ d = {}
57+ dpath .new (d , "a/b/0/c/0" , "hello" )
58+ assert 'b' in d .get ("a" , {})
59+ assert isinstance (d ["a" ]["b" ], list )
60+ assert len (d ["a" ]["b" ]) == 1
61+ assert 'c' in d ["a" ]["b" ][0 ]
62+ assert isinstance (d ["a" ]["b" ][0 ]["c" ], list )
63+ assert len (d ["a" ]["b" ][0 ]["c" ]) == 1
64+
65+
66+ def test_int_segment_dict_type_check ():
67+ d = {"a" : {"b" : {"0" : {}}}}
68+ dpath .new (d , "a/b/0/c/0" , "hello" )
69+ assert "b" in d .get ("a" , {})
70+ assert isinstance (d ["a" ]["b" ], dict )
71+ assert '0' in d ["a" ]["b" ]
72+ assert 'c' in d ["a" ]["b" ]["0" ]
73+ assert isinstance (d ["a" ]["b" ]["0" ]["c" ], list )
74+
75+
5576def test_set_new_list_path_with_separator ():
5677 # This test kills many birds with one stone, forgive me
5778 dict = {
You can’t perform that action at this time.
0 commit comments