]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-119897: Add test for lambda generator invocation (#120658)
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Tue, 18 Jun 2024 09:45:23 +0000 (10:45 +0100)
committerGitHub <noreply@github.com>
Tue, 18 Jun 2024 09:45:23 +0000 (10:45 +0100)
gh-120467: Add test for lambda generator invocation

Lib/test/test_generators.py

index 4598e62122b09ccd80e60c5d1bb4f687c4948f7d..daa65718bfc9055ffc7aeee912a55f99c8dd7aa8 100644 (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'