summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_annotationlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_annotationlib.py')
-rw-r--r--Lib/test/test_annotationlib.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py
index e459d27..e4dcdb6 100644
--- a/Lib/test/test_annotationlib.py
+++ b/Lib/test/test_annotationlib.py
@@ -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):