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

Method test_base_dataclass

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

Source from the content-addressed store, hash-verified

4384 self.assertIsInstance(c, Base2)
4385
4386 def test_base_dataclass(self):
4387 @dataclass
4388 class Base1:
4389 x: int
4390 class Base2:
4391 pass
4392 C = make_dataclass('C',
4393 [('y', int)],
4394 bases=(Base1, Base2))
4395 with self.assertRaisesRegex(TypeError, 'required positional'):
4396 c = C(2)
4397 c = C(1, 2)
4398 self.assertIsInstance(c, C)
4399 self.assertIsInstance(c, Base1)
4400 self.assertIsInstance(c, Base2)
4401
4402 self.assertEqual((c.x, c.y), (1, 2))
4403
4404 def test_init_var(self):
4405 def post_init(self, y):

Callers

nothing calls this directly

Calls 5

make_dataclassFunction · 0.85
assertRaisesRegexMethod · 0.80
assertIsInstanceMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected