From 2788ef14712ffa419fb56805d2d09afde84e0a3b Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Mon, 10 Apr 2017 23:15:12 +0200 Subject: [PATCH] #N/A: Make `missing_space_before_subcommand` handle aliases correctly --- tests/rules/test_missing_space_before_subcommand.py | 13 ++----------- thefuck/rules/missing_space_before_subcommand.py | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/rules/test_missing_space_before_subcommand.py b/tests/rules/test_missing_space_before_subcommand.py index be491ea0..c0e17694 100644 --- a/tests/rules/test_missing_space_before_subcommand.py +++ b/tests/rules/test_missing_space_before_subcommand.py @@ -4,12 +4,6 @@ from thefuck.rules.missing_space_before_subcommand import ( from tests.utils import Command -@pytest.fixture(autouse=True) -def which(mocker): - return mocker.patch('thefuck.rules.missing_space_before_subcommand.which', - return_value=None) - - @pytest.fixture(autouse=True) def all_executables(mocker): return mocker.patch( @@ -23,11 +17,8 @@ def test_match(script): assert match(Command(script)) -@pytest.mark.parametrize('script, which_result', [ - ('git branch', '/usr/bin/git'), - ('vimfile', None)]) -def test_not_match(script, which_result, which): - which.return_value = which_result +@pytest.mark.parametrize('script', ['git branch' 'vimfile']) +def test_not_match(script): assert not match(Command(script)) diff --git a/thefuck/rules/missing_space_before_subcommand.py b/thefuck/rules/missing_space_before_subcommand.py index 41c8166d..6a165a3d 100644 --- a/thefuck/rules/missing_space_before_subcommand.py +++ b/thefuck/rules/missing_space_before_subcommand.py @@ -9,7 +9,7 @@ def _get_executable(script_part): def match(command): - return (not which(command.script_parts[0]) + return (not command.script_parts[0] in get_all_executables() and _get_executable(command.script_parts[0]))