Repository navigation
gh-156376: Fix test_environ_path_cwd when NoDefaultCurrentDirectoryInExePath is set - #161277
Open
ArtyomSimitian wants to merge 2 commits into
Open
ArtyomSimitian wants to merge 2 commits into
ArtyomSimitian wants to merge 2 commits into
Conversation
…toryInExePath is set
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.
test_shutil.test_environ_path_cwdon Windows relied on the user'sNoDefaultCurrentDirectoryInExePathenvironment setting and was thereforenon-deterministic. When that variable is set, Windows skips searching the
current directory, so
shutil.which()returned'file.exe'instead of theexpected
'.\\file.exe'and the test failed.This change mocks
shutil._win_path_needs_curdirto returnTruefor thepart of the test that expects the current-directory lookup, so the result no
longer depends on the machine's settings.
test_cwd_win32already uses thesame approach. On non-Windows platforms
which()never calls that function,so behavior there is unchanged.
Tested on Windows 11 (debug build):
NoDefaultCurrentDirectoryInExePath=1: before the fix,test_environ_path_cwdfailed in bothTestWhichandTestWhichBytes.After the fix, all 54
whichtests pass (2 skipped as non-win32).whichtests pass.test_shutil: 238 run, 0 failures.No other
whichtests were affected by the variable.