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 5265df2 commit f7241f1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_funcs.py
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 f7241f1

Please sign in to comment.