1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-30 22:54:14 +00:00

Add is_app/for_app helpers

This commit is contained in:
nvbn
2015-08-27 16:08:29 +03:00
parent edf77a90ad
commit 9103c1ffd5
2 changed files with 47 additions and 1 deletions

View File

@@ -2,8 +2,9 @@ import pytest
from mock import Mock
from thefuck.utils import wrap_settings,\
memoize, get_closest, get_all_executables, replace_argument, \
get_all_matched_commands
get_all_matched_commands, is_app, for_app
from thefuck.types import Settings
from tests.utils import Command
@pytest.mark.parametrize('override, old, new', [
@@ -93,3 +94,25 @@ def test_replace_argument(args, result):
'service-status', 'service-unbind'])])
def test_get_all_matched_commands(stderr, result):
assert list(get_all_matched_commands(stderr)) == result
@pytest.mark.usefixtures('no_memoize')
@pytest.mark.parametrize('script, names, result', [
('git diff', ['git', 'hub'], True),
('hub diff', ['git', 'hub'], True),
('hg diff', ['git', 'hub'], False)])
def test_is_app(script, names, result):
assert is_app(Command(script), *names) == result
@pytest.mark.usefixtures('no_memoize')
@pytest.mark.parametrize('script, names, result', [
('git diff', ['git', 'hub'], True),
('hub diff', ['git', 'hub'], True),
('hg diff', ['git', 'hub'], False)])
def test_for_app(script, names, result):
@for_app(*names)
def match(command, settings):
return True
assert match(Command(script), None) == result