Beispiel #1
0
    def test_deep_find_with_nested_dicts(self):
        with self.subTest('With element on first level of nesting!'):
            nested_dicts = {
                'a': {1, 2},
                'b': {
                    'c': 3,
                    'd': {
                        'g': 5
                    }
                },
                'apple': 42
            }

            self.assertEqual(deep_find(nested_dicts, 'apple'), 42)

        with self.subTest('With element on third level of nesting!'):
            nested_dicts = {
                'a': {1, 2},
                'b': {
                    'c': 3,
                    'd': {
                        'apple': 42
                    }
                },
                'c': 3
            }

            self.assertEqual(deep_find(nested_dicts, 'apple'), 42)
Beispiel #2
0
    def test_deep_find_finds_nothing(self):
        list_with_dicts = [{}, {'apple': 42}, 'Anton']

        self.assertEqual(deep_find(list_with_dicts, 'pineaplle'), None)
Beispiel #3
0
    def test_deep_find_list_with_dicts(self):
        list_with_dicts = [{}, {'apple': 42}, 'Anton']

        self.assertEqual(deep_find(list_with_dicts, 'apple'), 42)
Beispiel #4
0
    def test_deep_find_dict_with_nested_lists(self):
        dict_with_nested_lists = {'a': [[[{'b': 2}, {'apple': 42}]]], 'c': 3}

        self.assertEqual(deep_find(dict_with_nested_lists, 'apple'), 42)
Beispiel #5
0
 def test_deep_find_value_is_list_with_dict(self):
     key = "z"
     result = "Z"
     self.assertEqual(graphs.deep_find(self.data, key), result)
Beispiel #6
0
 def test_deep_find_iterable(self):
     key = "f"
     result = True
     self.assertEqual(graphs.deep_find(self.data, key), result)
Beispiel #7
0
 def test_deep_find_of_iterable_value(self):
     key = "g"
     result = [1, 2, 3]
     self.assertEqual(graphs.deep_find(self.d, key), result)
Beispiel #8
0
 def test_deep_find_value_is_dict(self):
     key = "d"
     result = [True, False]
     self.assertEqual(graphs.deep_find(self.data, key), result)
Beispiel #9
0
 def test_deep_find_simple_data(self):
     key = "a"
     self.assertEqual(graphs.deep_find(self.data, key), self.data[key])
Beispiel #10
0
 def test_deep_find_no_key_found(self):
     key = "X"
     self.assertEqual(graphs.deep_find(self.data, key), None)