Skip to content

Commit 0c4c2e6

Browse files
authored
Move several typing tests to a proper class, refs GH-28563 (GH-29126)
1 parent 311910b commit 0c4c2e6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Lib/test/test_typing.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,22 @@ class BadType(BadBase):
32823282
self.assertNotIn('bad', sys.modules)
32833283
self.assertEqual(get_type_hints(BadType), {'foo': tuple, 'bar': list})
32843284

3285+
def test_forward_ref_and_final(self):
3286+
# https://bugs.python.org/issue45166
3287+
hints = get_type_hints(ann_module5)
3288+
self.assertEqual(hints, {'name': Final[str]})
3289+
3290+
hints = get_type_hints(ann_module5.MyClass)
3291+
self.assertEqual(hints, {'value': Final})
3292+
3293+
def test_top_level_class_var(self):
3294+
# https://bugs.python.org/issue45166
3295+
with self.assertRaisesRegex(
3296+
TypeError,
3297+
r'typing.ClassVar\[int\] is not valid as type argument',
3298+
):
3299+
get_type_hints(ann_module6)
3300+
32853301

32863302
class GetUtilitiesTestCase(TestCase):
32873303
def test_get_origin(self):
@@ -3345,22 +3361,6 @@ class C(Generic[T]): pass
33453361
(Concatenate[int, P], int))
33463362
self.assertEqual(get_args(list | str), (list, str))
33473363

3348-
def test_forward_ref_and_final(self):
3349-
# https://bugs.python.org/issue45166
3350-
hints = get_type_hints(ann_module5)
3351-
self.assertEqual(hints, {'name': Final[str]})
3352-
3353-
hints = get_type_hints(ann_module5.MyClass)
3354-
self.assertEqual(hints, {'value': Final})
3355-
3356-
def test_top_level_class_var(self):
3357-
# https://bugs.python.org/issue45166
3358-
with self.assertRaisesRegex(
3359-
TypeError,
3360-
r'typing.ClassVar\[int\] is not valid as type argument',
3361-
):
3362-
get_type_hints(ann_module6)
3363-
33643364

33653365
class CollectionsAbcTests(BaseTestCase):
33663366

0 commit comments

Comments
 (0)