mirror of
https://github.com/python/cpython.git
synced 2025-11-14 15:56:48 +00:00
gh-128673: Increase coverage of typing.get_type_hints (#128674)
This commit is contained in:
parent
ea39c8b08d
commit
43ac9f5059
1 changed files with 19 additions and 0 deletions
|
|
@ -7152,6 +7152,25 @@ class GetTypeHintTests(BaseTestCase):
|
||||||
self.assertEqual(get_type_hints(C, format=annotationlib.Format.STRING),
|
self.assertEqual(get_type_hints(C, format=annotationlib.Format.STRING),
|
||||||
{'x': 'undefined'})
|
{'x': 'undefined'})
|
||||||
|
|
||||||
|
def test_get_type_hints_format_function(self):
|
||||||
|
def func(x: undefined) -> undefined: ...
|
||||||
|
|
||||||
|
# VALUE
|
||||||
|
with self.assertRaises(NameError):
|
||||||
|
get_type_hints(func)
|
||||||
|
with self.assertRaises(NameError):
|
||||||
|
get_type_hints(func, format=annotationlib.Format.VALUE)
|
||||||
|
|
||||||
|
# FORWARDREF
|
||||||
|
self.assertEqual(
|
||||||
|
get_type_hints(func, format=annotationlib.Format.FORWARDREF),
|
||||||
|
{'x': ForwardRef('undefined'), 'return': ForwardRef('undefined')},
|
||||||
|
)
|
||||||
|
|
||||||
|
# STRING
|
||||||
|
self.assertEqual(get_type_hints(func, format=annotationlib.Format.STRING),
|
||||||
|
{'x': 'undefined', 'return': 'undefined'})
|
||||||
|
|
||||||
|
|
||||||
class GetUtilitiesTestCase(TestCase):
|
class GetUtilitiesTestCase(TestCase):
|
||||||
def test_get_origin(self):
|
def test_get_origin(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue