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

Method test_helper_astuple

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

Source from the content-addressed store, hash-verified

1811 self.assertTrue(d["mp"] is not c.mp) # make sure defaultdict is copied
1812
1813 def test_helper_astuple(self):
1814 # Basic tests for astuple(), it should return a new tuple.
1815 @dataclass
1816 class C:
1817 x: int
1818 y: int = 0
1819 c = C(1)
1820
1821 self.assertEqual(astuple(c), (1, 0))
1822 self.assertEqual(astuple(c), astuple(c))
1823 self.assertIsNot(astuple(c), astuple(c))
1824 c.y = 42
1825 self.assertEqual(astuple(c), (1, 42))
1826 self.assertIs(type(astuple(c)), tuple)
1827
1828 def test_helper_astuple_raises_on_classes(self):
1829 # astuple() should raise on a class object.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected