[Python-checkins] Move several typing tests to a proper class, refs GH-28563 (GH-29126)

ambv webhook-mailer at python.org
Thu Oct 21 16:16:59 EDT 2021


https://github.com/python/cpython/commit/0c4c2e6213f348dc98a787e385cde0a480e80ee9
commit: 0c4c2e6213f348dc98a787e385cde0a480e80ee9
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: ambv <lukasz at langa.pl>
date: 2021-10-21T22:16:50+02:00
summary:

Move several typing tests to a proper class, refs GH-28563 (GH-29126)

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 032fe91c7a840..b1414dc82bae0 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3282,6 +3282,22 @@ class BadType(BadBase):
         self.assertNotIn('bad', sys.modules)
         self.assertEqual(get_type_hints(BadType), {'foo': tuple, 'bar': list})
 
+    def test_forward_ref_and_final(self):
+        # https://bugs.python.org/issue45166
+        hints = get_type_hints(ann_module5)
+        self.assertEqual(hints, {'name': Final[str]})
+
+        hints = get_type_hints(ann_module5.MyClass)
+        self.assertEqual(hints, {'value': Final})
+
+    def test_top_level_class_var(self):
+        # https://bugs.python.org/issue45166
+        with self.assertRaisesRegex(
+            TypeError,
+            r'typing.ClassVar\[int\] is not valid as type argument',
+        ):
+            get_type_hints(ann_module6)
+
 
 class GetUtilitiesTestCase(TestCase):
     def test_get_origin(self):
@@ -3345,22 +3361,6 @@ class C(Generic[T]): pass
                          (Concatenate[int, P], int))
         self.assertEqual(get_args(list | str), (list, str))
 
-    def test_forward_ref_and_final(self):
-        # https://bugs.python.org/issue45166
-        hints = get_type_hints(ann_module5)
-        self.assertEqual(hints, {'name': Final[str]})
-
-        hints = get_type_hints(ann_module5.MyClass)
-        self.assertEqual(hints, {'value': Final})
-
-    def test_top_level_class_var(self):
-        # https://bugs.python.org/issue45166
-        with self.assertRaisesRegex(
-            TypeError,
-            r'typing.ClassVar\[int\] is not valid as type argument',
-        ):
-            get_type_hints(ann_module6)
-
 
 class CollectionsAbcTests(BaseTestCase):
 



More information about the Python-checkins mailing list