gh-119897: Add test for lambda generator invocation (#120658)
gh-120467: Add test for lambda generator invocation
This commit is contained in:
parent
2cf47389e2
commit
73dc1c678e
@ -6,6 +6,7 @@ import doctest
|
|||||||
import unittest
|
import unittest
|
||||||
import weakref
|
import weakref
|
||||||
import inspect
|
import inspect
|
||||||
|
import types
|
||||||
|
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
@ -89,9 +90,12 @@ class FinalizationTest(unittest.TestCase):
|
|||||||
self.assertEqual(gc.garbage, old_garbage)
|
self.assertEqual(gc.garbage, old_garbage)
|
||||||
|
|
||||||
def test_lambda_generator(self):
|
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
|
# like the equivalent function
|
||||||
f = lambda: (yield 1)
|
f = lambda: (yield 1)
|
||||||
|
self.assertIsInstance(f(), types.GeneratorType)
|
||||||
|
self.assertEqual(next(f()), 1)
|
||||||
|
|
||||||
def g(): return (yield 1)
|
def g(): return (yield 1)
|
||||||
|
|
||||||
# test 'yield from'
|
# test 'yield from'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user