File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -377,12 +377,14 @@ def __len__(self):
377
377
378
378
@pytest .mark .parametrize ('strict' , [True , False ])
379
379
def test_defaultdict (strict ):
380
- """Test that defaultdict is accepted and converted to regular dict"""
381
380
v = SchemaValidator (cs .dict_schema (keys_schema = cs .str_schema (), values_schema = cs .int_schema ()))
382
381
383
- dd = defaultdict (int , {'a' : 1 , 'b' : 2 })
382
+ dd = defaultdict (int , {})
383
+ # simulate move to end, since defaultdict doesn't have it
384
+ dd ['a' ] = 1
385
+ dd ['b' ] = 2
386
+ dd ['a' ] = dd .pop ('a' )
384
387
385
388
result = v .validate_python (dd , strict = strict )
386
- assert result == {'a' : 1 , 'b' : 2 }
387
- assert isinstance (result , dict )
388
- assert not isinstance (result , defaultdict )
389
+ assert list (result .keys ()) == list (dd .keys ()) == ['b' , 'a' ]
390
+ assert result == {'b' : 2 , 'a' : 1 }
You can’t perform that action at this time.
0 commit comments