Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/test/test_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,12 @@ def test_environ_path_cwd(self):
# PATH=':': explicitly looks in the current directory
with os_helper.EnvironmentVarGuard() as env:
env['PATH'] = os.pathsep
if sys.platform == "win32":
# shutil.which() only searches the current directory when
# _winapi.NeedCurrentDirectoryForExePath() returns true, which
# in turn consults NoDefaultCurrentDirectoryInExePath. Unset
# it so an ambient value cannot change what is searched.
env.unset('NoDefaultCurrentDirectoryInExePath')
with unittest.mock.patch('os.confstr', return_value=self.dir, \
create=True), \
support.swap_attr(os, 'defpath', self.dir):
Expand Down
Loading