2015-07-10 17:58:41 +03:00
|
|
|
import pytest
|
2015-07-20 21:04:49 +03:00
|
|
|
from thefuck.rules.no_command import match, get_new_command
|
2015-07-10 17:58:41 +03:00
|
|
|
from tests.utils import Command
|
2015-04-08 19:00:03 +02:00
|
|
|
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
@pytest.fixture(autouse=True)
|
2015-07-20 21:04:49 +03:00
|
|
|
def get_all_executables(mocker):
|
|
|
|
mocker.patch('thefuck.rules.no_command.get_all_executables',
|
|
|
|
return_value=['vim', 'apt-get', 'fsck'])
|
2015-04-08 19:00:03 +02:00
|
|
|
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
@pytest.mark.usefixtures('no_memoize')
|
2015-07-20 21:04:49 +03:00
|
|
|
def test_match():
|
2015-09-07 13:00:29 +03:00
|
|
|
assert match(Command(stderr='vom: not found', script='vom file.py'))
|
|
|
|
assert match(Command(stderr='fucck: not found', script='fucck'))
|
|
|
|
assert not match(Command(stderr='qweqwe: not found', script='qweqwe'))
|
|
|
|
assert not match(Command(stderr='some text', script='vom file.py'))
|
2015-06-10 20:53:35 -03:00
|
|
|
|
|
|
|
|
2015-07-10 17:58:41 +03:00
|
|
|
@pytest.mark.usefixtures('no_memoize')
|
2015-07-20 21:04:49 +03:00
|
|
|
def test_get_new_command():
|
2015-06-10 20:53:35 -03:00
|
|
|
assert get_new_command(
|
2015-07-10 17:58:41 +03:00
|
|
|
Command(stderr='vom: not found',
|
2015-09-07 13:00:29 +03:00
|
|
|
script='vom file.py')) == ['vim file.py']
|
2015-06-10 20:53:35 -03:00
|
|
|
assert get_new_command(
|
2015-07-10 17:58:41 +03:00
|
|
|
Command(stderr='fucck: not found',
|
2015-09-07 13:00:29 +03:00
|
|
|
script='fucck')) == ['fsck']
|