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

gh-119897: Add test for lambda generator invocation (GH-120658)
(cherry picked from commit 73dc1c678e)


gh-120467: Add test for lambda generator invocation

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-06-18 12:16:42 +02:00 committed by GitHub
parent 451cb71cc8
commit 692874cdcc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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'