2015-04-23 15:25:12 +09:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.pip_unknown_command import match, get_new_command
|
2015-04-25 02:35:26 +02:00
|
|
|
from tests.utils import Command
|
2015-04-23 15:25:12 +09:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def pip_unknown_cmd():
|
|
|
|
return '''ERROR: unknown command "instatl" - maybe you meant "install"'''
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def pip_unknown_cmd_without_recommend():
|
|
|
|
return '''ERROR: unknown command "i"'''
|
|
|
|
|
|
|
|
|
|
|
|
def test_match(pip_unknown_cmd, pip_unknown_cmd_without_recommend):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(Command('pip instatl', stderr=pip_unknown_cmd))
|
2015-04-25 02:35:26 +02:00
|
|
|
assert not match(Command('pip i',
|
2015-09-07 13:00:29 +03:00
|
|
|
stderr=pip_unknown_cmd_without_recommend))
|
2015-04-23 15:25:12 +09:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command(pip_unknown_cmd):
|
2015-09-07 13:00:29 +03:00
|
|
|
assert get_new_command(Command('pip instatl',
|
|
|
|
stderr=pip_unknown_cmd)) == 'pip install'
|