Repository navigation
Rebuild cached fixtures when declared dependency definitions change - #15177
Open
rongali-commits wants to merge 1 commit into
Open
rongali-commits wants to merge 1 commit into
rongali-commits wants to merge 1 commit into
Conversation
Fixes pytest-dev#2844. Guard finalizers from an older dependency generation and cover overrides with native pytester regression tests. AI assistance: OpenAI Codex. Rongali Chaitanya reviewed and understood the implementation and tests.
This branch has not been deployed
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.
When two test modules override the same declared dependency, a shared session fixture can keep module A's value while module B requires its own value. This can occur even when the shared fixture's own parameter has not changed.
Record the dependency definitions used to build the cached result and check them before reuse. Rebuild on a changed definition, and guard cleanup callbacks so a previous dependency cannot tear down a replacement generation. Exclude the synthetic
requestdefinition, which is created separately per request. Preserve the existing parameter cache-key behaviour.Fixes #2844.
Ten regression cases cover session/module scope, parametrized/ordinary dependencies, both module orders, repeated reuse, teardown order, stale callbacks, and cached setup errors followed by an override. Six fail against unchanged source; all ten pass with the candidate. The boundary is declared dependencies; this does not attempt general dynamic
getfixturevaluetracking.Validation on Windows:
The full runs use a short temporary path, UTF-8 subprocess output, stable generated metadata, disabled automatic external plugins and Hypothesis explicitly loaded at startup. No test deselections or warning suppression were used. Hosted validation for submitted head
0cf8c08a0a10d47a12890a839e152cf0983844ceis now complete: all 36 reported checks are successful, including Windows, Ubuntu and macOS test jobs, packaging, docs, pre-commit, changelog and coverage checks. Test workflow, PR checks.Two batches of five paired whole-process comparisons on 3,000-test synthetic workloads:
The isolated cached-method benchmark was slower by 15–27%; the numbers above measure complete invocations. Large timing variation across and within batches means the whole-process experiment is inconclusive. No performance improvement or zero-cost claim is made. The isolated cost remains a review concern. Public raw measurements and reproduction harnesses are available; a stable benchmark environment may be needed for a precise assessment.
AI assistance: OpenAI Codex helped prepare the implementation and tests. Rongali Chaitanya reviewed the concrete patch and confirmed understanding of dependency invalidation and the stale-finalizer guard. Reviewed patch SHA-256:
54afc118b882450e3e958120fc7b2e17f353ef3b3067be9816c986ee98571dde. The submitting contributor is responsible for the change and maintainer feedback.Checklist:
Fixes #2844.Codex assistance is disclosed above and in the commit message; no agent email identity is claimed.