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)
def test_deep_find_finds_nothing(self): list_with_dicts = [{}, {'apple': 42}, 'Anton'] self.assertEqual(deep_find(list_with_dicts, 'pineaplle'), None)
def test_deep_find_list_with_dicts(self): list_with_dicts = [{}, {'apple': 42}, 'Anton'] self.assertEqual(deep_find(list_with_dicts, 'apple'), 42)
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)
def test_deep_find_value_is_list_with_dict(self): key = "z" result = "Z" self.assertEqual(graphs.deep_find(self.data, key), result)
def test_deep_find_iterable(self): key = "f" result = True self.assertEqual(graphs.deep_find(self.data, key), result)
def test_deep_find_of_iterable_value(self): key = "g" result = [1, 2, 3] self.assertEqual(graphs.deep_find(self.d, key), result)
def test_deep_find_value_is_dict(self): key = "d" result = [True, False] self.assertEqual(graphs.deep_find(self.data, key), result)
def test_deep_find_simple_data(self): key = "a" self.assertEqual(graphs.deep_find(self.data, key), self.data[key])
def test_deep_find_no_key_found(self): key = "X" self.assertEqual(graphs.deep_find(self.data, key), None)