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

Method test_generic_dynamic

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

Source from the content-addressed store, hash-verified

2169 self.assertEqual(c.new_method(), 1.0)
2170
2171 def test_generic_dynamic(self):
2172 T = TypeVar('T')
2173
2174 @dataclass
2175 class Parent(Generic[T]):
2176 x: T
2177 Child = make_dataclass('Child', [('y', T), ('z', Optional[T], None)],
2178 bases=(Parent[int], Generic[T]), namespace={'other': 42})
2179 self.assertIs(Child[int](1, 2).z, None)
2180 self.assertEqual(Child[int](1, 2, 3).z, 3)
2181 self.assertEqual(Child[int](1, 2, 3).other, 42)
2182 # Check that type aliases work correctly.
2183 Alias = Child[T]
2184 self.assertEqual(Alias[int](1, 2).x, 1)
2185 # Check MRO resolution.
2186 self.assertEqual(Child.__mro__, (Child, Parent, Generic, object))
2187
2188 def test_dataclasses_pickleable(self):
2189 global P, Q, R

Callers

nothing calls this directly

Calls 4

assertIsMethod · 0.95
assertEqualMethod · 0.95
TypeVarClass · 0.85
make_dataclassFunction · 0.85

Tested by

no test coverage detected