fix(execution): enter and exit context manager resources per item in EACH mode (#124) - #125
Merged
Merged
Conversation
added 3 commits
July 28, 2026 01:32
…EACH mode (#124) ### Summary Fixes #124 where context-manager resources in EACH-mode steps were entered once before the first item and exited once after the last item, instead of wrapping each individual item invocation. ### Changes - Sync & Async argument builders: defer context manager resolution when step is in EACH mode - Sync & Async step runners: wrap item execution with ExitStack / AsyncExitStack inside generate() - Sync & Async executors: pass deferred_resources map down to step runners - Documentation: update resources.md with EACH mode per-item resource lifecycle rules ### Tests - Added sync unit tests in test_runner_each_resource_lifecycle.py - Added async unit tests in test_async_runner_each_resource_lifecycle.py - Verified test parity gate (test_parity.py) and sync/async parity suites
… instead of nested ExitStack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #124 where context-manager resources in EACH-mode steps were entered once before the first item and exited once after the last item, instead of wrapping each individual item invocation.
Changes
ExitStack/AsyncExitStackinsidegenerate()deferred_resourcesmap to step runnersresources.mdwith EACH mode per-item resource lifecycle rulesTests
test_runner_each_resource_lifecycle.pytest_async_runner_each_resource_lifecycle.pytest_parity.py) and sync/async parity suites