mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-118647: Add defaults to typing.Generator and typing.AsyncGenerator (#118648)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
9fd33af5ac
commit
8419f01673
4 changed files with 51 additions and 9 deletions
|
@ -7289,6 +7289,17 @@ class CollectionsAbcTests(BaseTestCase):
|
|||
g = foo()
|
||||
self.assertIsSubclass(type(g), typing.Generator)
|
||||
|
||||
def test_generator_default(self):
|
||||
g1 = typing.Generator[int]
|
||||
g2 = typing.Generator[int, None, None]
|
||||
self.assertEqual(get_args(g1), (int, type(None), type(None)))
|
||||
self.assertEqual(get_args(g1), get_args(g2))
|
||||
|
||||
g3 = typing.Generator[int, float]
|
||||
g4 = typing.Generator[int, float, None]
|
||||
self.assertEqual(get_args(g3), (int, float, type(None)))
|
||||
self.assertEqual(get_args(g3), get_args(g4))
|
||||
|
||||
def test_no_generator_instantiation(self):
|
||||
with self.assertRaises(TypeError):
|
||||
typing.Generator()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue