mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-19 09:10:47 +01:00
Fix test cases
This commit is contained in:
parent
8a8ade1e6b
commit
309fe8f6ee
@ -1,17 +1,9 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from thefuck.rules.hostscli import no_command, no_website, get_new_command, \
|
from thefuck.rules.hostscli import no_website, get_new_command, match
|
||||||
match
|
|
||||||
from tests.utils import Command
|
from tests.utils import Command
|
||||||
|
|
||||||
|
|
||||||
no_command = '''
|
no_website_long = '''
|
||||||
Usage: hostscli [OPTIONS] COMMAND [ARGS]...
|
|
||||||
|
|
||||||
%s "invalid".
|
|
||||||
''' % no_command
|
|
||||||
|
|
||||||
|
|
||||||
no_website = '''
|
|
||||||
%s:
|
%s:
|
||||||
|
|
||||||
No Domain list found for website: a_website_that_does_not_exist
|
No Domain list found for website: a_website_that_does_not_exist
|
||||||
@ -24,17 +16,16 @@ type `hostscli websites` to see a list of websites that you can block/unblock
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('command', [
|
||||||
Command('hostscli invalid', stderr=no_command)])
|
Command(
|
||||||
|
'sudo hostscli block a_website_that_does_not_exist',
|
||||||
|
stderr=no_website_long)])
|
||||||
def test_match(command):
|
def test_match(command):
|
||||||
assert match(command)
|
assert match(command)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, result', [
|
@pytest.mark.parametrize('command, result', [(
|
||||||
(Command(
|
Command(
|
||||||
'hostscli invalid', stderr=no_command), ['hostscli --help']),
|
|
||||||
(Command(
|
|
||||||
'sudo hostscli block a_website_that_does_not_exist',
|
'sudo hostscli block a_website_that_does_not_exist',
|
||||||
stderr=no_website),
|
stderr=no_website_long), ['hostscli websites'])])
|
||||||
['hostscli websites'])])
|
|
||||||
def test_get_new_command(command, result):
|
def test_get_new_command(command, result):
|
||||||
assert get_new_command(command) == result
|
assert get_new_command(command) == result
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from thefuck.utils import for_app, replace_command
|
from thefuck.utils import replace_command
|
||||||
|
|
||||||
no_command = "Error: No such command"
|
no_command = "Error: No such command"
|
||||||
no_website = "hostscli.errors.WebsiteImportError"
|
no_website = "hostscli.errors.WebsiteImportError"
|
||||||
|
|
||||||
|
|
||||||
@for_app("hostscli")
|
|
||||||
def match(command):
|
def match(command):
|
||||||
errors = [no_command, no_website]
|
errors = [no_command, no_website]
|
||||||
for error in errors:
|
for error in errors:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user