Skip to content

Instantly share code, notes, and snippets.

@gidgid
Last active November 7, 2020 19:34
Show Gist options
  • Save gidgid/4de576a0c9b7c217e076619d412825d5 to your computer and use it in GitHub Desktop.
Save gidgid/4de576a0c9b7c217e076619d412825d5 to your computer and use it in GitHub Desktop.
Nested dictionaries make us coupled to the internal structure
def test_hobbies_names_is_reliant_on_hobbies_to_have_names():
employee = {
"name": "John",
"age": 42,
"hobbies": [
{"name": "Rock Climbing", "_id": "1234"},
{"name": "Acrobatics", "_id": "5678"},
],
}
hobbies_names = {hobby["name"] for hobby in employee["hobbies"]}
assert hobbies_names == {"Rock Climbing", "Acrobatics"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment