GH-128534: Instrument branches for async for loops. (GH-130569)

This commit is contained in:
Mark Shannon 2025-02-27 09:36:41 +00:00 committed by GitHub
parent fda056e64b
commit 2a18e80695
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 140 additions and 35 deletions

View file

@ -1657,6 +1657,29 @@ class TestBranchAndJumpEvents(CheckEvents):
in_loop,
exit_loop])
def test_async_for(self):
def func():
async def gen():
yield 2
yield 3
async def foo():
async for y in gen():
2
pass # line 3
try:
foo().send(None)
except StopIteration:
pass
self.check_events(func, recorders = BRANCHES_RECORDERS, expected = [
('branch left', 'foo', 1, 1),
('branch left', 'foo', 1, 1),
('branch right', 'foo', 1, 3),
('branch left', 'func', 12, 12)])
class TestBranchConsistency(MonitoringTestBase, unittest.TestCase):