fix: clear build directory cache in pytest fixture to avoid stale references#3743
Merged
frostming merged 2 commits intopdm-project:mainfrom Mar 4, 2026
Merged
fix: clear build directory cache in pytest fixture to avoid stale references#3743frostming merged 2 commits intopdm-project:mainfrom
frostming merged 2 commits intopdm-project:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3743 +/- ##
==========================================
+ Coverage 85.86% 85.88% +0.02%
==========================================
Files 118 118
Lines 12372 12374 +2
Branches 2060 2060
==========================================
+ Hits 10623 10628 +5
+ Misses 1176 1173 -3
Partials 573 573
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Use object.__setattr__() to set read-only _key property in packaging < 26 - In packaging >= 26, the __replace__() method is used instead - This allows the code to pass both mypy and ruff linters - Added detailed comment explaining version-specific behavior Fixes mypy error: Property "_key" defined in "Version" is read-only [misc]
frostming
approved these changes
Mar 4, 2026
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.
Pull Request Checklist
news/describing what is new.Problem
When executing
pdm run test tests/cli/test_others.py::test_show_package_on_pypi, the test fails with:Root Cause
The issue occurs when multiple PDM commands are executed sequentially in the same test using the same
Coreinstance:Command 1 (
pdm show ipython):create_temp_dir()creates temp directory → stored in_build_dir_cacheexit_stack.close()deletes the temp directoryCommand 2 (
pdm show requests):Command 3 (
pdm show --name requests):The root cause is
PreparedCandidate._build_dir_cache(aClassVar[dict]) persisting across multiple command executions within the same test fixture.Solution
Clear the cache in the
pdmpytest fixture's cleanup phase afterexit_stack.close():