]> granicus.if.org Git - python/commitdiff
Add one more test for typing.Final (GH-13588)
authorIvan Levkivskyi <levkivskyi@gmail.com>
Sun, 26 May 2019 23:54:13 +0000 (00:54 +0100)
committerGitHub <noreply@github.com>
Sun, 26 May 2019 23:54:13 +0000 (00:54 +0100)
Lib/test/test_typing.py

index 088db9c012066d3bb49b623b7127c9af955e3ae6..46b7621182d6fd6ad0fcb447e7a4c70ddb9a7fd4 100644 (file)
@@ -1772,6 +1772,11 @@ class ForwardRefTests(BaseTestCase):
         hints = get_type_hints(ns['C'].foo)
         self.assertEqual(hints, {'a': ns['C'], 'return': ns['D']})
 
+    def test_final_forward_ref(self):
+        self.assertEqual(gth(Loop, globals())['attr'], Final[Loop])
+        self.assertNotEqual(gth(Loop, globals())['attr'], Final[int])
+        self.assertNotEqual(gth(Loop, globals())['attr'], Final)
+
 
 class OverloadTests(BaseTestCase):
 
@@ -1858,6 +1863,9 @@ class CSub(B):
 class G(Generic[T]):
     lst: ClassVar[List[T]] = []
 
+class Loop:
+    attr: Final['Loop']
+
 class NoneAndForward:
     parent: 'NoneAndForward'
     meaning: None