Skip to content

Commit 558d6db

Browse files
committed
Update re-evaluate test to test generic type
1 parent c6065ad commit 558d6db

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

Lib/test/test_annotationlib.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,26 +1683,14 @@ def test_fwdref_invalid_syntax(self):
16831683
with self.assertRaises(SyntaxError):
16841684
fr.evaluate()
16851685

1686-
def test_re_evaluate(self):
1686+
def test_re_evaluate_generics(self):
1687+
global alias
16871688
class C:
1688-
x: alias
1689+
x: alias[int]
16891690

16901691
evaluated = get_annotations(C, format=Format.FORWARDREF)["x"].evaluate(format=Format.FORWARDREF)
1691-
alias = int
1692-
self.assertIs(evaluated.evaluate(), int)
1693-
1694-
del alias
1695-
evaluated = get_annotations(C, format=Format.FORWARDREF)["x"].evaluate(format=Format.FORWARDREF)
1696-
with self.assertRaises(NameError):
1697-
evaluated.evaluate()
1698-
1699-
class C:
1700-
x: alias2
1701-
1702-
evaluated = get_annotations(C, format=Format.FORWARDREF)["x"].evaluate(format=Format.FORWARDREF)
1703-
global alias2
1704-
alias2 = str
1705-
self.assertIs(evaluated.evaluate(), str)
1692+
alias = list
1693+
self.assertEqual(evaluated.evaluate(), list[int])
17061694

17071695

17081696
class TestAnnotationLib(unittest.TestCase):

0 commit comments

Comments
 (0)