Exemple #1
0
 def test_allows_new_keys_if_new_keys_allowed(
         self, base_dict, custom_dict, expected_dict):
     custom_dict['key5'] = 5.0
     expected_dict['key5'] = 5.0
     computed_dict = update_nested_dict(
         base_dict, custom_dict, allow_new_keys=True)
     assert computed_dict == expected_dict
Exemple #2
0
 def test_raises_keyerror_if_new_key_by_default(
         self, base_dict, custom_dict, expected_dict):
     custom_dict['key5'] = 5.0
     expected_dict['key5'] = 5.0
     with pytest.raises(KeyError):
         computed_dict = update_nested_dict(
             base_dict, custom_dict)
Exemple #3
0
 def test_returned_dict_is_deepcopy(
     self, base_dict):
     computed_dict = update_nested_dict(base_dict, {})
     assert id(computed_dict) != id(base_dict)
     assert id(computed_dict['key1']) != id(base_dict['key1'])
Exemple #4
0
 def test_raises_typeerror_if_replacement_type_does_not_match(
         self, base_dict, custom_dict, expected_dict):
     custom_dict['key2']['key2.1'] = '2'
     with pytest.raises(TypeError):
         computed_dict = update_nested_dict(base_dict, custom_dict)
         assert computed_dict == expected_dict
Exemple #5
0
 def test_updates_nested_keys(
         self, base_dict, custom_dict, expected_dict):
     computed_dict = update_nested_dict(base_dict, custom_dict)
     assert computed_dict == expected_dict