Skip to content

Commit

Permalink
Add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Dec 16, 2021
1 parent 6435098 commit 734fb2e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,21 @@ def test_asdict_preserve_order(self, cls):

assert [a.name for a in fields(cls)] == list(dict_instance.keys())

def test_retain_tuple_key(self):
"""
retain_collect_types also retains keys.
"""

@attr.s
class A(object):
a = attr.ib()

instance = A({(1,): 1})

assert {"a": {(1,): 1}} == attr.asdict(
instance, retain_collection_types=True
)

def test_tuple_keys(self):
"""
If a key is collection type, retain_collection_types is False,
Expand All @@ -212,7 +227,8 @@ class A(object):
a = attr.ib()

instance = A({(1,): 1})
attr.asdict(instance, tuple_keys=True)

assert {"a": {(1,): 1}} == attr.asdict(instance, tuple_keys=True)

def test_tuple_keys_retain_caught(self, C):
"""
Expand Down

0 comments on commit 734fb2e

Please sign in to comment.