(self)
| 5806 | ... |
| 5807 | |
| 5808 | def test_parameter_detection(self): |
| 5809 | self.assertEqual(List[T].__parameters__, (T,)) |
| 5810 | self.assertEqual(List[List[T]].__parameters__, (T,)) |
| 5811 | class A: |
| 5812 | __parameters__ = (T,) |
| 5813 | # Bare classes should be skipped |
| 5814 | for a in (List, list): |
| 5815 | for b in (A, int, TypeVar, TypeVarTuple, ParamSpec, types.GenericAlias, Union): |
| 5816 | with self.subTest(generic=a, sub=b): |
| 5817 | with self.assertRaisesRegex(TypeError, '.* is not a generic class'): |
| 5818 | a[b][str] |
| 5819 | # Duck-typing anything that looks like it has __parameters__. |
| 5820 | # These tests are optional and failure is okay. |
| 5821 | self.assertEqual(List[A()].__parameters__, (T,)) |
| 5822 | # C version of GenericAlias |
| 5823 | self.assertEqual(list[A()].__parameters__, (T,)) |
| 5824 | |
| 5825 | def test_non_generic_subscript(self): |
| 5826 | T = TypeVar('T') |
nothing calls this directly
no test coverage detected