|
|
|
@ -49,6 +49,26 @@ class FinalizationTest(unittest.TestCase): |
|
|
|
self.assertTrue(finalized) |
|
|
|
self.assertEqual(gc.garbage, old_garbage) |
|
|
|
|
|
|
|
def test_lambda_generator(self): |
|
|
|
# Issue #23192: Test that a lambda returning a generator behaves |
|
|
|
# like the equivalent function |
|
|
|
f = lambda: (yield 1) |
|
|
|
def g(): return (yield 1) |
|
|
|
|
|
|
|
# test 'yield from' |
|
|
|
f2 = lambda: (yield from g()) |
|
|
|
def g2(): return (yield from g()) |
|
|
|
|
|
|
|
f3 = lambda: (yield from f()) |
|
|
|
def g3(): return (yield from f()) |
|
|
|
|
|
|
|
for gen_fun in (f, g, f2, g2, f3, g3): |
|
|
|
gen = gen_fun() |
|
|
|
self.assertEqual(next(gen), 1) |
|
|
|
with self.assertRaises(StopIteration) as cm: |
|
|
|
gen.send(2) |
|
|
|
self.assertEqual(cm.exception.value, 2) |
|
|
|
|
|
|
|
|
|
|
|
class ExceptionTest(unittest.TestCase): |
|
|
|
# Tests for the issue #23353: check that the currently handled exception |
|
|
|
|