Skip to content

Instantly share code, notes, and snippets.

@guissalustiano
Created November 21, 2021 04:33
Show Gist options
  • Save guissalustiano/3a01d8140b57a9ec61f9ddcd2239f46d to your computer and use it in GitHub Desktop.
Save guissalustiano/3a01d8140b57a9ec61f9ddcd2239f46d to your computer and use it in GitHub Desktop.
from util import flatten_dict
def test_flatten_dict_nivel_1():
assert flatten_dict({'a': 1, 'b': 2}) == {'a': 1, 'b': 2}
def test_flatten_dict_nivel_3():
assert flatten_dict({'a': 1, 'b': {'c': 2, 'd': 3}}) == \
{'a': 1, 'b.c': 2, 'b.d': 3}
def test_flatten_dict_nivel_4():
assert flatten_dict({'a': {'b': {'c': {'d': 1}}}}) == {'a.b.c.d': 1}
def test_flatten_dict_nivel_separador():
assert flatten_dict({'a': {'b': 1}}, '_') == {'a_b': 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment