8000 Move several typing tests to a proper class by sobolevn · Pull Request #29126 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Move several typing tests to a proper class #29126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):

Expand Down
0