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

43 lines
1.3 KiB
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, get_all_callables
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 _safe(mocker):
mocker.patch('thefuck.rules.no_command._safe', return_value=[])
@pytest.fixture(autouse=True)
def get_aliases(mocker):
mocker.patch('thefuck.rules.no_command.get_aliases',
return_value=['vim', 'apt-get', 'fsck', 'fuck'])
@pytest.mark.usefixtures('no_memoize')
def test_get_all_callables(*args):
2015-07-10 15:58:41 +01:00
all_callables = get_all_callables()
assert 'vim' in all_callables
assert 'fsck' in all_callables
assert 'fuck' not in all_callables
2015-04-08 18:00:03 +01:00
2015-07-10 15:58:41 +01:00
@pytest.mark.usefixtures('no_memoize')
def test_match(*args):
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(*args):
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'