1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-27 23:52:41 +01:00

#534: Move “is arg a url?” logic to a function

This function will be used in `get_new_command`.
This commit is contained in:
Pablo Santiago Blum de Aguiar
2016-08-11 22:10:49 -03:00
parent fbea803a9b
commit a169575b0f
2 changed files with 36 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
import pytest
from thefuck.rules.open import match, get_new_command
from thefuck.rules.open import is_arg_url, match, get_new_command
from tests.utils import Command
@@ -10,11 +10,26 @@ def stderr(script):
@pytest.mark.parametrize('script', [
'open foo.com',
'open foo.ly',
'open foo.org',
'open foo.net',
'open foo.se',
'open foo.edu',
'open foo.info',
'open foo.io',
'open foo.ly',
'open foo.me',
'open foo.net',
'open foo.org',
'open foo.se',
'open www.foo.ru'])
def test_is_arg_url(script):
assert is_arg_url(Command(script))
@pytest.mark.parametrize('script', ['open foo', 'open bar.txt', 'open egg.doc'])
def test_not_is_arg_url(script):
assert not is_arg_url(Command(script))
@pytest.mark.parametrize('script', [
'open foo.com',
'xdg-open foo.com',
'gnome-open foo.com',
'kde-open foo.com'])
@@ -23,11 +38,6 @@ def test_match(script, stderr):
@pytest.mark.parametrize('script, new_command', [
('open foo.com', 'open http://foo.com'),
('open foo.ly', 'open http://foo.ly'),
('open foo.org', 'open http://foo.org'),
('open foo.net', 'open http://foo.net'),
('open foo.se', 'open http://foo.se'),
('open foo.io', 'open http://foo.io'),
('xdg-open foo.io', 'xdg-open http://foo.io'),
('gnome-open foo.io', 'gnome-open http://foo.io'),