MCPcopy Index your code
hub / github.com/python/cpython / test_helper_asdict_nested

Method test_helper_asdict_nested

Lib/test/test_dataclasses/__init__.py:1662–1677  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1660 self.assertEqual(c.y, [])
1661
1662 def test_helper_asdict_nested(self):
1663 @dataclass
1664 class UserId:
1665 token: int
1666 group: int
1667 @dataclass
1668 class User:
1669 name: str
1670 id: UserId
1671 u = User('Joe', UserId(123, 1))
1672 d = asdict(u)
1673 self.assertEqual(d, {'name': 'Joe', 'id': {'token': 123, 'group': 1}})
1674 self.assertIsNot(asdict(u), asdict(u))
1675 u.id.group = 2
1676 self.assertEqual(asdict(u), {'name': 'Joe',
1677 'id': {'token': 123, 'group': 2}})
1678
1679 def test_helper_asdict_builtin_containers(self):
1680 @dataclass

Callers

nothing calls this directly

Calls 5

assertEqualMethod · 0.95
assertIsNotMethod · 0.95
UserIdClass · 0.85
asdictFunction · 0.85
UserClass · 0.70

Tested by

no test coverage detected