Skip to content

[3.13] gh-119897: Add test for lambda generator invocation (GH-120658) #120673

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
Jun 18, 2024
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
6 changes: 5 additions & 1 deletion Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest
import weakref
import inspect
import types

from test import support

Expand Down Expand Up @@ -89,9 +90,12 @@ def gen():
self.assertEqual(gc.garbage, old_garbage)

def test_lambda_generator(self):
# Issue #23192: Test that a lambda returning a generator behaves
# bpo-23192, gh-119897: Test that a lambda returning a generator behaves
# like the equivalent function
f = lambda: (yield 1)
self.assertIsInstance(f(), types.GeneratorType)
self.assertEqual(next(f()), 1)

def g(): return (yield 1)

# test 'yield from'
Expand Down
Loading