8000 [3.12] gh-108000: Test that `lambda` also has `__type_params__` (GH-1… · python/cpython@e0244e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0244e8

Browse files
[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 a8d440b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent 2576303 commit e0244e8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Lib/test/test_funcattrs.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,19 @@ def test___qualname__(self):
194194
def test___type_params__(self):
195195
def generic[T](): pass
196196
def not_generic(): pass
197+
lambda_ = lambda: ...
197198
T, = generic.__type_params__
198199
self.assertIsInstance(T, typing.TypeVar)
199200
self.assertEqual(generic.__type_params__, (T,))
200-
self.assertEqual(not_generic.__type_params__, ())
201-
with self.assertRaises(TypeError):
202-
del not_generic.__type_params__
203-
with self.assertRaises(TypeError):
204-
not_generic.__type_params__ = 42
205-
not_generic.__type_params__ = (T,)
206-
self.assertEqual(not_generic.__type_params__, (T,))
201+
for func in (not_generic, lambda_):
202+
with self.subTest(func=func):
203+
self.assertEqual(func.__type_params__, ())
204+
with self.assertRaises(TypeError):
205+
del func.__type_params__
206+
with self.assertRaises(TypeError):
207+
func.__type_params__ = 42
208+
func.__type_params__ = (T,)
209+
self.assertEqual(func.__type_params__, (T,))
207210

208211
def test___code__(self):
209212
num_one, num_two = 7, 8

0 commit comments

Comments
 (0)
0