Skip to content

Commit f7241f1

Browse files
committed
Add missing test
1 parent 5265df2 commit f7241f1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/test_funcs.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,21 @@ def test_asdict_preserve_order(self, cls):
199199

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

202+
def test_retain_tuple_key(self):
203+
"""
204+
retain_collect_types also retains keys.
205+
"""
206+
207+
@attr.s
208+
class A(object):
209+
a = attr.ib()
210+
211+
instance = A({(1,): 1})
212+
213+
assert {"a": {(1,): 1}} == attr.asdict(
214+
instance, retain_collection_types=True
215+
)
216+
202217
def test_tuple_keys(self):
203218
"""
204219
If a key is collection type, retain_collection_types is False,
@@ -212,7 +227,8 @@ class A(object):
212227
a = attr.ib()
213228

214229
instance = A({(1,): 1})
215-
attr.asdict(instance, tuple_keys=True)
230+
231+
assert {"a": {(1,): 1}} == attr.asdict(instance, tuple_keys=True)
216232

217233
def test_tuple_keys_retain_caught(self, C):
218234
"""

0 commit comments

Comments
 (0)