1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 10:11:14 +00:00

#534: Use a stderr fixture on open rule tests

This commit is contained in:
Pablo Santiago Blum de Aguiar 2016-08-10 22:20:12 -03:00
parent 51415a5cb1
commit fbea803a9b

View File

@ -3,29 +3,34 @@ from thefuck.rules.open import match, get_new_command
from tests.utils import Command from tests.utils import Command
@pytest.mark.parametrize('command', [ @pytest.fixture
Command(script='open foo.com'), def stderr(script):
Command(script='open foo.ly'), return 'The file {} does not exist.\n'.format(script.split(' ', 1)[1])
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.mark.parametrize('command, new_command', [ @pytest.mark.parametrize('script', [
(Command('open foo.com'), 'open http://foo.com'), 'open foo.com',
(Command('open foo.ly'), 'open http://foo.ly'), 'open foo.ly',
(Command('open foo.org'), 'open http://foo.org'), 'open foo.org',
(Command('open foo.net'), 'open http://foo.net'), 'open foo.net',
(Command('open foo.se'), 'open http://foo.se'), 'open foo.se',
(Command('open foo.io'), 'open http://foo.io'), 'open foo.io',
(Command('xdg-open foo.io'), 'xdg-open http://foo.io'), 'xdg-open foo.com',
(Command('gnome-open foo.io'), 'gnome-open http://foo.io'), 'gnome-open foo.com',
(Command('kde-open foo.io'), 'kde-open http://foo.io')]) 'kde-open foo.com'])
def test_get_new_command(command, new_command): def test_match(script, stderr):
assert get_new_command(command) == new_command assert match(Command(script, stderr=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'),
('kde-open foo.io', 'kde-open http://foo.io')])
def test_get_new_command(script, new_command, stderr):
assert get_new_command(Command(script, stderr=stderr)) == new_command