gh-119897: Add test for lambda generator invocation (#120658)

gh-120467: Add test for lambda generator invocation
This commit is contained in:
Irit Katriel 2024-06-18 10:45:23 +01:00 committed by GitHub
parent 2cf47389e2
commit 73dc1c678e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import doctest
import unittest
import weakref
import inspect
import types
from test import support
@ -89,9 +90,12 @@ class FinalizationTest(unittest.TestCase):
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'