(self)
| 5914 | ... |
| 5915 | |
| 5916 | def test_parameter_detection(self): |
| 5917 | self.assertEqual(List[T].__parameters__, (T,)) |
| 5918 | self.assertEqual(List[List[T]].__parameters__, (T,)) |
| 5919 | class A: |
| 5920 | __parameters__ = (T,) |
| 5921 | # Bare classes should be skipped |
| 5922 | for a in (List, list): |
| 5923 | for b in (A, int, TypeVar, TypeVarTuple, ParamSpec, types.GenericAlias, Union): |
| 5924 | with self.subTest(generic=a, sub=b): |
| 5925 | with self.assertRaisesRegex(TypeError, '.* is not a generic class'): |
| 5926 | a[b][str] |
| 5927 | # Duck-typing anything that looks like it has __parameters__. |
| 5928 | # These tests are optional and failure is okay. |
| 5929 | self.assertEqual(List[A()].__parameters__, (T,)) |
| 5930 | # C version of GenericAlias |
| 5931 | self.assertEqual(list[A()].__parameters__, (T,)) |
| 5932 | |
| 5933 | def test_non_generic_subscript(self): |
| 5934 | T = TypeVar('T') |
nothing calls this directly
no test coverage detected