mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
#N/A: Ensure that command doesn't exists in no_command
rule
This commit is contained in:
parent
4c2fc490f2
commit
ca787a1cba
@ -21,15 +21,20 @@ def history_without_current(mocker):
|
||||
('vom file.py', 'vom: not found'),
|
||||
('fucck', 'fucck: not found'),
|
||||
('got commit', 'got: command not found')])
|
||||
def test_match(script, stderr):
|
||||
def test_match(mocker, script, stderr):
|
||||
mocker.patch('thefuck.rules.no_command.which', return_value=None)
|
||||
|
||||
assert match(Command(script, stderr=stderr))
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('no_memoize')
|
||||
@pytest.mark.parametrize('script, stderr', [
|
||||
('qweqwe', 'qweqwe: not found'),
|
||||
('vom file.py', 'some text')])
|
||||
def test_not_match(script, stderr):
|
||||
@pytest.mark.parametrize('script, stderr, which', [
|
||||
('qweqwe', 'qweqwe: not found', None),
|
||||
('vom file.py', 'some text', None),
|
||||
('vim file.py', 'vim: not found', 'vim')])
|
||||
def test_not_match(mocker, script, stderr, which):
|
||||
mocker.patch('thefuck.rules.no_command.which', return_value=which)
|
||||
|
||||
assert not match(Command(script, stderr=stderr))
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
from difflib import get_close_matches
|
||||
from thefuck.utils import get_all_executables, \
|
||||
get_valid_history_without_current, get_closest
|
||||
get_valid_history_without_current, get_closest, which
|
||||
from thefuck.specific.sudo import sudo_support
|
||||
|
||||
|
||||
@sudo_support
|
||||
def match(command):
|
||||
return (command.script_parts
|
||||
return (not which(command.script_parts[0])
|
||||
and 'not found' in command.stderr
|
||||
and bool(get_close_matches(command.script_parts[0],
|
||||
get_all_executables())))
|
||||
|
Loading…
x
Reference in New Issue
Block a user