mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 12:06:04 +00:00
parent
40ab4eb62d
commit
78ef9eec88
@ -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')])
|
||||
|
@ -118,7 +118,7 @@ def get_all_executables():
|
||||
tf_entry_points = ['thefuck', 'fuck']
|
||||
|
||||
bins = [exe.name.decode('utf8') if six.PY2 else exe.name
|
||||
for path in os.environ.get('PATH', '').split(':')
|
||||
for path in os.environ.get('PATH', '').split(os.pathsep)
|
||||
for exe in _safe(lambda: list(Path(path).iterdir()), [])
|
||||
if not _safe(exe.is_dir, True)
|
||||
and exe.name not in tf_entry_points]
|
||||
|
Loading…
x
Reference in New Issue
Block a user