1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-28 16:12:36 +01:00

#682: Unify work with output in classic and instant mode

This commit is contained in:
Vladimir Iakovlev
2017-08-31 17:58:56 +02:00
parent 96843fc6cd
commit 4625d8503d
237 changed files with 1322 additions and 1332 deletions

View File

@@ -1,9 +1,9 @@
import pytest
from thefuck.rules.sudo_command_from_user_path import match, get_new_command
from tests.utils import Command
from thefuck.types import Command
stderr = 'sudo: {}: command not found'
output = 'sudo: {}: command not found'
@pytest.fixture(autouse=True)
@@ -12,28 +12,28 @@ def which(mocker):
return_value='/usr/bin/app')
@pytest.mark.parametrize('script, stderr', [
('sudo npm install -g react-native-cli', stderr.format('npm')),
('sudo -u app appcfg update .', stderr.format('appcfg'))])
def test_match(script, stderr):
assert match(Command(script, stderr=stderr))
@pytest.mark.parametrize('script, output', [
('sudo npm install -g react-native-cli', output.format('npm')),
('sudo -u app appcfg update .', output.format('appcfg'))])
def test_match(script, output):
assert match(Command(script, output))
@pytest.mark.parametrize('script, stderr, which_result', [
('npm --version', stderr.format('npm'), '/usr/bin/npm'),
@pytest.mark.parametrize('script, output, which_result', [
('npm --version', output.format('npm'), '/usr/bin/npm'),
('sudo npm --version', '', '/usr/bin/npm'),
('sudo npm --version', stderr.format('npm'), None)])
def test_not_match(which, script, stderr, which_result):
('sudo npm --version', output.format('npm'), None)])
def test_not_match(which, script, output, which_result):
which.return_value = which_result
assert not match(Command(script, stderr=stderr))
assert not match(Command(script, output))
@pytest.mark.parametrize('script, stderr, result', [
@pytest.mark.parametrize('script, output, result', [
('sudo npm install -g react-native-cli',
stderr.format('npm'),
output.format('npm'),
'sudo env "PATH=$PATH" npm install -g react-native-cli'),
('sudo -u app appcfg update .',
stderr.format('appcfg'),
output.format('appcfg'),
'sudo -u app env "PATH=$PATH" appcfg update .')])
def test_get_new_command(script, stderr, result):
assert get_new_command(Command(script, stderr=stderr)) == result
def test_get_new_command(script, output, result):
assert get_new_command(Command(script, output)) == result