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:
parent
51415a5cb1
commit
fbea803a9b
@ -3,29 +3,34 @@ from thefuck.rules.open import 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.ly',
|
||||
'open foo.org',
|
||||
'open foo.net',
|
||||
'open foo.se',
|
||||
'open foo.io',
|
||||
'xdg-open foo.com',
|
||||
'gnome-open foo.com',
|
||||
'kde-open foo.com'])
|
||||
def test_match(script, stderr):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user