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

Method test_helper_asdict

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

Source from the content-addressed store, hash-verified

1619 self.assertNotIn("__dataclass_fields__", printed_traceback)
1620
1621 def test_helper_asdict(self):
1622 # Basic tests for asdict(), it should return a new dictionary.
1623 @dataclass
1624 class C:
1625 x: int
1626 y: int
1627 c = C(1, 2)
1628
1629 self.assertEqual(asdict(c), {'x': 1, 'y': 2})
1630 self.assertEqual(asdict(c), asdict(c))
1631 self.assertIsNot(asdict(c), asdict(c))
1632 c.x = 42
1633 self.assertEqual(asdict(c), {'x': 42, 'y': 2})
1634 self.assertIs(type(asdict(c)), dict)
1635
1636 def test_helper_asdict_raises_on_classes(self):
1637 # asdict() should raise on a class object.

Callers

nothing calls this directly

Calls 5

assertEqualMethod · 0.95
assertIsNotMethod · 0.95
assertIsMethod · 0.95
asdictFunction · 0.85
CClass · 0.70

Tested by

no test coverage detected