From 734fb2e89ec083d5401ba35c1544122b780965f6 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 15 Dec 2021 09:33:29 +0100 Subject: [PATCH] Add missing test --- tests/test_funcs.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_funcs.py b/tests/test_funcs.py index 24a201a56..2b818f4c6 100644 --- a/tests/test_funcs.py +++ b/tests/test_funcs.py @@ -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, @@ -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): """