diff options
author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2021-04-28 15:38:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 15:38:14 (GMT) |
commit | 859577c24981d6b36960d309f99f7fc810fe75c2 (patch) | |
tree | 172b56f0aec20bc47c0fe0d39e44e6e040d0e63d /Lib/test | |
parent | c1a9535989cc7323099725503519a17f79d083f5 (diff) | |
download | cpython-859577c24981d6b36960d309f99f7fc810fe75c2.zip cpython-859577c24981d6b36960d309f99f7fc810fe75c2.tar.gz cpython-859577c24981d6b36960d309f99f7fc810fe75c2.tar.bz2 |
bpo-41559: Change PEP 612 implementation to pure Python (#25449)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_genericalias.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index fd024dc..9f92739 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -353,6 +353,12 @@ class BaseTest(unittest.TestCase): self.assertEqual(repr(C4[dict]).split(".")[-1], "Callable[[int, dict], str]") self.assertEqual(C4[dict], Callable[[int, dict], str]) + # substitute a nested GenericAlias (both typing and the builtin + # version) + C5 = Callable[[typing.List[T], tuple[K, T], V], int] + self.assertEqual(C5[int, str, float], + Callable[[typing.List[int], tuple[str, int], float], int]) + with self.subTest("Testing type erasure"): class C1(Callable): def __call__(self): @@ -391,5 +397,16 @@ class BaseTest(unittest.TestCase): self.assertEqual(repr(C1), "collections.abc.Callable" "[typing.Concatenate[int, ~P], int]") + with self.subTest("Testing TypeErrors"): + with self.assertRaisesRegex(TypeError, "variables left in"): + alias[int] + P = typing.ParamSpec('P') + C1 = Callable[P, T] + with self.assertRaisesRegex(TypeError, "many arguments for"): + C1[int, str, str] + with self.assertRaisesRegex(TypeError, "few arguments for"): + C1[int] + + if __name__ == "__main__": unittest.main() |