diff options
| author | Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> | 2020-12-29 02:26:19 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-29 02:26:19 (GMT) |
| commit | efb1f0918fad2ba3346a986b0e958dc5753a7bbe (patch) | |
| tree | 035a6ce4a6e3778e74a68ee6ea614190e20811e7 /Lib/test | |
| parent | a6d63a20df63b3fd33b5e1f629e7f96d00f6ae39 (diff) | |
| download | cpython-efb1f0918fad2ba3346a986b0e958dc5753a7bbe.zip cpython-efb1f0918fad2ba3346a986b0e958dc5753a7bbe.tar.gz cpython-efb1f0918fad2ba3346a986b0e958dc5753a7bbe.tar.bz2 | |
bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942)
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_typing.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 3dcc31f..3b8efe1 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3021,6 +3021,7 @@ class GetUtilitiesTestCase(TestCase): self.assertIs(get_origin(Callable), collections.abc.Callable) self.assertIs(get_origin(list[int]), list) self.assertIs(get_origin(list), None) + self.assertIs(get_origin(list | str), types.Union) def test_get_args(self): T = TypeVar('T') @@ -3053,6 +3054,11 @@ class GetUtilitiesTestCase(TestCase): self.assertEqual(get_args(collections.abc.Callable[[], str]), ([], str)) self.assertEqual(get_args(collections.abc.Callable[[int], str]), get_args(Callable[[int], str])) + P = ParamSpec('P') + self.assertEqual(get_args(Callable[P, int]), (P, int)) + self.assertEqual(get_args(Callable[Concatenate[int, P], int]), + (Concatenate[int, P], int)) + self.assertEqual(get_args(list | str), (list, str)) class CollectionsAbcTests(BaseTestCase): |
