mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-119180: Add evaluate functions for type params and type aliases (#122212)
This commit is contained in:
parent
cbac8a3888
commit
ae192262ad
11 changed files with 385 additions and 159 deletions
|
@ -773,6 +773,25 @@ class TestGetAnnotations(unittest.TestCase):
|
|||
)
|
||||
|
||||
|
||||
class TestCallEvaluateFunction(unittest.TestCase):
|
||||
def test_evaluation(self):
|
||||
def evaluate(format, exc=NotImplementedError):
|
||||
if format != 1:
|
||||
raise exc
|
||||
return undefined
|
||||
|
||||
with self.assertRaises(NameError):
|
||||
annotationlib.call_evaluate_function(evaluate, annotationlib.Format.VALUE)
|
||||
self.assertEqual(
|
||||
annotationlib.call_evaluate_function(evaluate, annotationlib.Format.FORWARDREF),
|
||||
annotationlib.ForwardRef("undefined"),
|
||||
)
|
||||
self.assertEqual(
|
||||
annotationlib.call_evaluate_function(evaluate, annotationlib.Format.SOURCE),
|
||||
"undefined",
|
||||
)
|
||||
|
||||
|
||||
class MetaclassTests(unittest.TestCase):
|
||||
def test_annotated_meta(self):
|
||||
class Meta(type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue