def test_skip_nested(self): dictionary = { "a": "1", "b": { "c": 2, "d": "3" }, "e": { "f": { "g": "4" } } } expected = {"a": "1", "b__d": "3", "e__f__g": "4"} actual = flatten(dictionary, skip=["c"]) assert actual == expected
def test_one_level_two(self): dictionary = {"a": {"b": 1, "c": 2}} assert {"a__b": 1, "a__c": 2} == flatten(dictionary)
def test_one_level(self): dictionary = {"a": {"b": 1}} assert {"a__b": 1} == flatten(dictionary)
def test_trivial_two(self): dictionary = {"a": 1, "b": 2} flat_dict = flatten(dictionary) assert {"a": 1, "b": 2} == flat_dict
def test_trivial(self): assert {"a": 1} == flatten({"a": 1})
def test_skip(self): dictionary = {"a": 1, "b": 2} flat_dict = flatten(dictionary, skip="b") assert {"a": 1} == flat_dict
def test_two_level_two(self): dictionary = {"a": {"b": {"c": 1}, "d": 2}} assert {"a__b__c": 1, "a__d": 2} == flatten(dictionary)
def test_two_level(self): dictionary = {"a": {"b": {"c": 1}}} assert {"a__b__c": 1} == flatten(dictionary)