Beispiel #1
0
 def test_str_tuple(self, test_filter, expected_result):
     assert dict_filter(self.test_dict,
                        filter=test_filter) == expected_result
     # test with a tuple as filter
     assert (dict_filter(
         self.test_dict,
         filter=escape_split(test_filter)) == expected_result)
Beispiel #2
0
 def test_fail_incorrect_type(self):
     with pytest.raises(PathAccessError):
         dict_filter({"data": 1}, filter="data.key")
Beispiel #3
0
 def test_fail_incorrect_filter(self):
     with pytest.raises(PathAccessError):
         dict_filter(self.test_dict, filter="data.DOESNOTEXIST")
Beispiel #4
0
 def test_list_position(self):
     assert dict_filter({"data": [0, "one"]}, filter="data.1") == "one"
Beispiel #5
0
 def test_none_filter(self):
     assert dict_filter(self.test_dict, filter=None) == self.test_dict
Beispiel #6
0
 def test_empty_filter(self):
     assert dict_filter(self.test_dict, filter="") == self.test_dict