Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes to pacman_not_found rule #1281

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/rules/test_pacman_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ def test_match_mocked(subp_mock, command):
assert match(command)


@pytest.mark.parametrize('command', [
Command('zaz -S llc', 'sh: zaz: command not found'),
Command('pikachu -S llc', 'sh: pikachu: command not found'),
Command('yogurt -S llc', 'sh: yogurt: command not found'),
Command('batman llc', 'sh: batman: command not found'),
Command('sudo batman llc', 'sudo: batman: command not found')])
@patch('thefuck.specific.archlinux.subprocess')
def test_not_match_mocked(subp_mock, command):
subp_mock.check_output.return_value = ""
assert not match(command)


@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
reason='Skip if pacman is not available')
@pytest.mark.parametrize('command, fixed', [
Expand Down
10 changes: 5 additions & 5 deletions thefuck/rules/pacman_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
yay -S llvm
"""

from thefuck.utils import replace_command
from thefuck.utils import for_app, replace_command
from thefuck.specific.archlinux import get_pkgfile, archlinux_env
from thefuck.specific.sudo import sudo_support


@sudo_support
@for_app('pacman', 'pikaur', 'yaourt', 'yay')
def match(command):
return (command.script_parts
and (command.script_parts[0] in ('pacman', 'yay', 'pikaur', 'yaourt')
or command.script_parts[0:2] == ['sudo', 'pacman'])
and 'error: target not found:' in command.output)
return 'error: target not found:' in command.output


def get_new_command(command):
Expand Down