mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-28 08:02:33 +01:00
#682: Unify work with output in classic and instant mode
This commit is contained in:
@@ -2,7 +2,7 @@ import pytest
|
||||
from mock import patch
|
||||
from thefuck.rules import pacman
|
||||
from thefuck.rules.pacman import match, get_new_command
|
||||
from tests.utils import Command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
pacman_cmd = getattr(pacman, 'pacman', 'pacman')
|
||||
@@ -20,15 +20,15 @@ extra/vim-python3 7.4.712-1 \t/usr/bin/vim'''
|
||||
@pytest.mark.skipif(not getattr(pacman, 'enabled_by_default', True),
|
||||
reason='Skip if pacman is not available')
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='vim', stderr='vim: command not found'),
|
||||
Command(script='sudo vim', stderr='sudo: vim: command not found')])
|
||||
Command('vim', 'vim: command not found'),
|
||||
Command('sudo vim', 'sudo: vim: command not found')])
|
||||
def test_match(command):
|
||||
assert match(command)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, return_value', [
|
||||
(Command(script='vim', stderr='vim: command not found'), PKGFILE_OUTPUT_VIM),
|
||||
(Command(script='sudo vim', stderr='sudo: vim: command not found'), PKGFILE_OUTPUT_VIM)])
|
||||
(Command('vim', 'vim: command not found'), PKGFILE_OUTPUT_VIM),
|
||||
(Command('sudo vim', 'sudo: vim: command not found'), PKGFILE_OUTPUT_VIM)])
|
||||
@patch('thefuck.specific.archlinux.subprocess')
|
||||
@patch.multiple(pacman, create=True, pacman=pacman_cmd)
|
||||
def test_match_mocked(subp_mock, command, return_value):
|
||||
@@ -37,8 +37,8 @@ def test_match_mocked(subp_mock, command, return_value):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='vim', stderr=''), Command(),
|
||||
Command(script='sudo vim', stderr=''), Command()])
|
||||
Command('vim', ''), Command('', ''),
|
||||
Command('sudo vim', ''), Command('', '')])
|
||||
def test_not_match(command):
|
||||
assert not match(command)
|
||||
|
||||
@@ -61,20 +61,20 @@ vim_possibilities = [s.format(pacman_cmd) for s in vim_possibilities]
|
||||
@pytest.mark.skipif(not getattr(pacman, 'enabled_by_default', True),
|
||||
reason='Skip if pacman is not available')
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('vim'), vim_possibilities),
|
||||
(Command('sudo vim'), sudo_vim_possibilities),
|
||||
(Command('convert'), ['{} -S extra/imagemagick && convert'.format(pacman_cmd)]),
|
||||
(Command('sudo convert'), ['{} -S extra/imagemagick && sudo convert'.format(pacman_cmd)])])
|
||||
(Command('vim', ''), vim_possibilities),
|
||||
(Command('sudo vim', ''), sudo_vim_possibilities),
|
||||
(Command('convert', ''), ['{} -S extra/imagemagick && convert'.format(pacman_cmd)]),
|
||||
(Command('sudo convert', ''), ['{} -S extra/imagemagick && sudo convert'.format(pacman_cmd)])])
|
||||
def test_get_new_command(command, new_command, mocker):
|
||||
assert get_new_command(command) == new_command
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command, return_value', [
|
||||
(Command('vim'), vim_possibilities, PKGFILE_OUTPUT_VIM),
|
||||
(Command('sudo vim'), sudo_vim_possibilities, PKGFILE_OUTPUT_VIM),
|
||||
(Command('convert'), ['{} -S extra/imagemagick && convert'.format(pacman_cmd)], PKGFILE_OUTPUT_CONVERT),
|
||||
(Command('sudo'), ['{} -S core/sudo && sudo'.format(pacman_cmd)], PKGFILE_OUTPUT_SUDO),
|
||||
(Command('sudo convert'), ['{} -S extra/imagemagick && sudo convert'.format(pacman_cmd)], PKGFILE_OUTPUT_CONVERT)])
|
||||
(Command('vim', ''), vim_possibilities, PKGFILE_OUTPUT_VIM),
|
||||
(Command('sudo vim', ''), sudo_vim_possibilities, PKGFILE_OUTPUT_VIM),
|
||||
(Command('convert', ''), ['{} -S extra/imagemagick && convert'.format(pacman_cmd)], PKGFILE_OUTPUT_CONVERT),
|
||||
(Command('sudo', ''), ['{} -S core/sudo && sudo'.format(pacman_cmd)], PKGFILE_OUTPUT_SUDO),
|
||||
(Command('sudo convert', ''), ['{} -S extra/imagemagick && sudo convert'.format(pacman_cmd)], PKGFILE_OUTPUT_CONVERT)])
|
||||
@patch('thefuck.specific.archlinux.subprocess')
|
||||
@patch.multiple(pacman, create=True, pacman=pacman_cmd)
|
||||
def test_get_new_command_mocked(subp_mock, command, new_command, return_value):
|
||||
|
Reference in New Issue
Block a user