mirror of
https://github.com/python/cpython.git
synced 2025-08-08 10:58:51 +00:00
[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 a8d440b383
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
2576303007
commit
e0244e85d0
1 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue