mirror of
				https://github.com/nvbn/thefuck.git
				synced 2025-10-30 14:44:05 +00:00 
			
		
		
		
	Merge branch 'master' of github.com:nvbn/thefuck
This commit is contained in:
		| @@ -1,31 +1,49 @@ | ||||
| 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 | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command', [ | ||||
|     Command(script='open foo.com'), | ||||
|     Command(script='open foo.ly'), | ||||
|     Command(script='open foo.org'), | ||||
|     Command(script='open foo.net'), | ||||
|     Command(script='open foo.se'), | ||||
|     Command(script='open foo.io'), | ||||
|     Command(script='xdg-open foo.com'), | ||||
|     Command(script='gnome-open foo.com'), | ||||
|     Command(script='kde-open foo.com')]) | ||||
| def test_match(command): | ||||
|     assert match(command) | ||||
| @pytest.fixture | ||||
| def stderr(script): | ||||
|     return 'The file {} does not exist.\n'.format(script.split(' ', 1)[1]) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('command, new_command', [ | ||||
|     (Command('open foo.com'), 'open http://foo.com'), | ||||
|     (Command('open foo.ly'), 'open http://foo.ly'), | ||||
|     (Command('open foo.org'), 'open http://foo.org'), | ||||
|     (Command('open foo.net'), 'open http://foo.net'), | ||||
|     (Command('open foo.se'), 'open http://foo.se'), | ||||
|     (Command('open foo.io'), 'open http://foo.io'), | ||||
|     (Command('xdg-open foo.io'), 'xdg-open http://foo.io'), | ||||
|     (Command('gnome-open foo.io'), 'gnome-open http://foo.io'), | ||||
|     (Command('kde-open foo.io'), 'kde-open http://foo.io')]) | ||||
| def test_get_new_command(command, new_command): | ||||
|     assert get_new_command(command) == new_command | ||||
| @pytest.mark.parametrize('script', [ | ||||
|     'open foo.com', | ||||
|     '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', | ||||
|     'open nonest']) | ||||
| def test_match(script, stderr): | ||||
|     assert match(Command(script, stderr=stderr)) | ||||
|  | ||||
|  | ||||
| @pytest.mark.parametrize('script, new_command', [ | ||||
|     ('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']), | ||||
|     ('kde-open foo.io', ['kde-open http://foo.io']), | ||||
|     ('open nonest', ['touch nonest && open nonest', | ||||
|                      'mkdir nonest && open nonest'])]) | ||||
| def test_get_new_command(script, new_command, stderr): | ||||
|     assert get_new_command(Command(script, stderr=stderr)) == new_command | ||||
|   | ||||
		Reference in New Issue
	
	Block a user