diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-08-17 10:51:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 10:51:07 (GMT) |
commit | e0244e85d09a3d2a40211c587891d908c35d277c (patch) | |
tree | a1566637483b315e32f34c99b7fd35eef62698d8 | |
parent | 25763030074e678b7e2d17a868355131f52d9a6b (diff) | |
download | cpython-e0244e85d09a3d2a40211c587891d908c35d277c.zip cpython-e0244e85d09a3d2a40211c587891d908c35d277c.tar.gz cpython-e0244e85d09a3d2a40211c587891d908c35d277c.tar.bz2 |
[3.12] gh-108000: Test that `lambda` also has `__type_params__` (GH-108002) (#108019)
gh-108000: Test that `lambda` also has `__type_params__` (GH-108002)
(cherry picked from commit a8d440b3837273926af5ce996162b019290ddad5)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r-- | Lib/test/test_funcattrs.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index e08d728..35b473d 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -194,16 +194,19 @@ class FunctionPropertiesTest(FuncAttrsTest): def test___type_params__(self): def generic[T](): pass def not_generic(): pass + lambda_ = lambda: ... T, = generic.__type_params__ self.assertIsInstance(T, typing.TypeVar) self.assertEqual(generic.__type_params__, (T,)) - self.assertEqual(not_generic.__type_params__, ()) - with self.assertRaises(TypeError): - del not_generic.__type_params__ - with self.assertRaises(TypeError): - not_generic.__type_params__ = 42 - not_generic.__type_params__ = (T,) - self.assertEqual(not_generic.__type_params__, (T,)) + for func in (not_generic, lambda_): + with self.subTest(func=func): + self.assertEqual(func.__type_params__, ()) + with self.assertRaises(TypeError): + del func.__type_params__ + with self.assertRaises(TypeError): + func.__type_params__ = 42 + func.__type_params__ = (T,) + self.assertEqual(func.__type_params__, (T,)) def test___code__(self): num_one, num_two = 7, 8 |