(self)
| 2144 | Alias = List[LabeledBox[int]] |
| 2145 | |
| 2146 | def test_generic_extending(self): |
| 2147 | S = TypeVar('S') |
| 2148 | T = TypeVar('T') |
| 2149 | |
| 2150 | @dataclass |
| 2151 | class Base(Generic[T, S]): |
| 2152 | x: T |
| 2153 | y: S |
| 2154 | |
| 2155 | @dataclass |
| 2156 | class DataDerived(Base[int, T]): |
| 2157 | new_field: str |
| 2158 | Alias = DataDerived[str] |
| 2159 | c = Alias(0, 'test1', 'test2') |
| 2160 | self.assertEqual(astuple(c), (0, 'test1', 'test2')) |
| 2161 | |
| 2162 | class NonDataDerived(Base[int, T]): |
| 2163 | def new_method(self): |
| 2164 | return self.y |
| 2165 | Alias = NonDataDerived[float] |
| 2166 | c = Alias(10, 1.0) |
| 2167 | self.assertEqual(c.new_method(), 1.0) |
| 2168 | |
| 2169 | def test_generic_dynamic(self): |
| 2170 | T = TypeVar('T') |
nothing calls this directly
no test coverage detected