1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-13 15:24:03 +01:00

#902: Use os.pathsep to split PATH env var (#917)

Fix #902
This commit is contained in:
Pablo Aguiar
2019-05-21 20:47:47 +02:00
committed by Vladimir Iakovlev
parent 40ab4eb62d
commit 78ef9eec88
2 changed files with 20 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
import pytest
import warnings
from mock import Mock, patch
from mock import Mock, call, patch
from thefuck.utils import default_settings, \
memoize, get_closest, get_all_executables, replace_argument, \
get_all_matched_commands, is_app, for_app, cache, \
@@ -76,6 +76,24 @@ def test_get_all_executables():
assert 'fuck' not in all_callables
@pytest.fixture
def os_environ_pathsep(monkeypatch, path, pathsep):
env = {'PATH': path}
monkeypatch.setattr('os.environ', env)
monkeypatch.setattr('os.pathsep', pathsep)
return env
@pytest.mark.usefixtures('no_memoize', 'os_environ_pathsep')
@pytest.mark.parametrize('path, pathsep', [
('/foo:/bar:/baz:/foo/bar', ':'),
(r'C:\\foo;C:\\bar;C:\\baz;C:\\foo\\bar', ';')])
def test_get_all_executables_pathsep(path, pathsep):
with patch('thefuck.utils.Path') as Path_mock:
get_all_executables()
Path_mock.assert_has_calls([call(p) for p in path.split(pathsep)], True)
@pytest.mark.parametrize('args, result', [
(('apt-get instol vim', 'instol', 'install'), 'apt-get install vim'),
(('git brnch', 'brnch', 'branch'), 'git branch')])