1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 10:51:11 +01:00
thefuck/tests/rules/test_no_command.py

30 lines
1009 B
Python
Raw Normal View History

2015-07-10 15:58:41 +01:00
import pytest
from thefuck.rules.no_command import match, get_new_command
2015-07-10 15:58:41 +01:00
from tests.utils import Command
2015-04-08 18:00:03 +01:00
2015-07-10 15:58:41 +01:00
@pytest.fixture(autouse=True)
def get_all_executables(mocker):
mocker.patch('thefuck.rules.no_command.get_all_executables',
return_value=['vim', 'apt-get', 'fsck'])
2015-04-08 18:00:03 +01:00
2015-07-10 15:58:41 +01:00
@pytest.mark.usefixtures('no_memoize')
def test_match():
2015-07-10 15:58:41 +01:00
assert match(Command(stderr='vom: not found', script='vom file.py'), None)
assert match(Command(stderr='fucck: not found', script='fucck'), None)
assert not match(Command(stderr='qweqwe: not found', script='qweqwe'), None)
assert not match(Command(stderr='some text', script='vom file.py'), None)
2015-07-10 15:58:41 +01:00
@pytest.mark.usefixtures('no_memoize')
def test_get_new_command():
assert get_new_command(
2015-07-10 15:58:41 +01:00
Command(stderr='vom: not found',
script='vom file.py'),
None) == ['vim file.py']
assert get_new_command(
2015-07-10 15:58:41 +01:00
Command(stderr='fucck: not found',
script='fucck'),
Command) == ['fsck']