mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[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:
parent
451cb71cc8
commit
692874cdcc
1 changed files with 5 additions and 1 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue