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

This commit is contained in:
Nikita Sobolev 2021-10-21 23:16:50 +03:00 committed by GitHub
parent 311910b31a
commit 0c4c2e6213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -3282,6 +3282,22 @@ class GetTypeHintTests(BaseTestCase):
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 GetUtilitiesTestCase(TestCase):
(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):