[Python-checkins] gh-108000: Test that `lambda` also has `__type_params__` (#108002)
JelleZijlstra
webhook-mailer at python.org
Wed Aug 16 09:22:22 EDT 2023
https://github.com/python/cpython/commit/a8d440b3837273926af5ce996162b019290ddad5
commit: a8d440b3837273926af5ce996162b019290ddad5
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2023-08-16T06:22:18-07:00
summary:
gh-108000: Test that `lambda` also has `__type_params__` (#108002)
files:
M Lib/test/test_funcattrs.py
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index e08d72877d8ae..35b473d5e9a0b 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -194,16 +194,19 @@ def test___qualname__(self):
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
More information about the Python-checkins
mailing list