MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_dataclass

Method test_dataclass

Lib/test/test_copy.py:964–978  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

962 copy.replace(p, x=1, error=2)
963
964 def test_dataclass(self):
965 from dataclasses import dataclass
966 @dataclass
967 class C:
968 x: int
969 y: int = 0
970
971 attrs = attrgetter('x', 'y')
972 c = C(11, 22)
973 self.assertEqual(attrs(copy.replace(c)), (11, 22))
974 self.assertEqual(attrs(copy.replace(c, x=1)), (1, 22))
975 self.assertEqual(attrs(copy.replace(c, y=2)), (11, 2))
976 self.assertEqual(attrs(copy.replace(c, x=1, y=2)), (1, 2))
977 with self.assertRaisesRegex(TypeError, 'unexpected keyword argument'):
978 copy.replace(c, x=1, error=2)
979
980
981class MiscTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

attrgetterClass · 0.90
assertRaisesRegexMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected