Add tests for switch_working_directory helper#10766
Open
SergioChan wants to merge 3 commits intopython-poetry:mainfrom
Open
Add tests for switch_working_directory helper#10766SergioChan wants to merge 3 commits intopython-poetry:mainfrom
SergioChan wants to merge 3 commits intopython-poetry:mainfrom
Conversation
Reviewer's GuideThis PR adds two pytest-based unit tests for the switch_working_directory helper to verify it correctly restores the original working directory on exceptions and optionally deletes the temporary directory when requested. File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Author
|
Follow-up pushed in Change
Targeted validation
|
Author
|
Pushed follow-up commit 0facb5c to fix the failing What changed (auto-fixes from the repo hooks):
Validation:
|
radoering
requested changes
Mar 15, 2026
Member
radoering
left a comment
There was a problem hiding this comment.
The two tests seem arbitrary. A complete test should test both aspects (cwd is changed (back) and cwd is only deleted if remove=True) - both under normal conditions and if there is an error. I think one parameterized test makes sense.
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
switch_working_directory()restores the original cwd when an exception is raisedremove=Truedeletes the temporary working directory after exiting the context managerFixes #9161
Summary by Sourcery
Add coverage for the switch_working_directory helper behavior.
Tests: