MCPcopy Create free account
hub / github.com/RustPython/RustPython / test_parameter_detection

Method test_parameter_detection

Lib/test/test_typing.py:5808–5823  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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')

Callers

nothing calls this directly

Calls 4

subTestMethod · 0.80
assertRaisesRegexMethod · 0.80
AClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected