-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect PATHEXT when looking for Win executable
... as idiomatic in Windows programming.
- Loading branch information
Showing
3 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
|
||
import mock | ||
import pytest | ||
|
||
from pipenv import utils | ||
|
||
|
||
# This module is run only on Windows. | ||
pytestmark = pytest.mark.skipif( | ||
os.name != 'nt', | ||
reason="only relevant on windows", | ||
) | ||
|
||
|
||
@mock.patch('os.path.isfile') | ||
@mock.patch('pipenv.utils.find_executable') | ||
def test_find_windows_executable(mocked_find_executable, mocked_isfile): | ||
mocked_isfile.return_value = False | ||
mocked_find_executable.return_value = None | ||
found = utils.find_windows_executable('fake/path', 'python') | ||
assert found is None | ||
|
||
assert mocked_isfile.call_count > 1 | ||
|
||
calls = [mock.call('fake/path/python')] + [ | ||
mock.call('fake/path/python{0}'.format(ext.lower())) | ||
for ext in os.environ['PATHEXT'].split(';') | ||
] | ||
assert mocked_isfile.mock_calls == calls |