mirror of
https://github.com/nvbn/thefuck.git
synced 2025-10-29 22:24:44 +00:00
#682: Unify work with output in classic and instant mode
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import pytest
|
||||
from thefuck.rules.grep_arguments_order import get_new_command, match
|
||||
from tests.utils import Command
|
||||
from thefuck.types import Command
|
||||
|
||||
stderr = 'grep: {}: No such file or directory'.format
|
||||
output = 'grep: {}: No such file or directory'.format
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@@ -16,25 +16,25 @@ def os_path(monkeypatch):
|
||||
('egrep test.py test', 'test'),
|
||||
('egrep -lir . test', 'test')])
|
||||
def test_match(script, file):
|
||||
assert match(Command(script, stderr=stderr(file)))
|
||||
assert match(Command(script, output(file)))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, stderr', [
|
||||
('cat test.py', stderr('test')),
|
||||
@pytest.mark.parametrize('script, output', [
|
||||
('cat test.py', output('test')),
|
||||
('grep test test.py', ''),
|
||||
('grep -lir test .', ''),
|
||||
('egrep test test.py', ''),
|
||||
('egrep -lir test .', '')])
|
||||
def test_not_match(script, stderr):
|
||||
assert not match(Command(script, stderr=stderr))
|
||||
def test_not_match(script, output):
|
||||
assert not match(Command(script, output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, stderr, result', [
|
||||
('grep test.py test', stderr('test'), 'grep test test.py'),
|
||||
('grep -lir . test', stderr('test'), 'grep -lir test .'),
|
||||
('grep . test -lir', stderr('test'), 'grep test -lir .'),
|
||||
('egrep test.py test', stderr('test'), 'egrep test test.py'),
|
||||
('egrep -lir . test', stderr('test'), 'egrep -lir test .'),
|
||||
('egrep . test -lir', stderr('test'), 'egrep test -lir .')])
|
||||
def test_get_new_command(script, stderr, result):
|
||||
assert get_new_command(Command(script, stderr=stderr)) == result
|
||||
@pytest.mark.parametrize('script, output, result', [
|
||||
('grep test.py test', output('test'), 'grep test test.py'),
|
||||
('grep -lir . test', output('test'), 'grep -lir test .'),
|
||||
('grep . test -lir', output('test'), 'grep test -lir .'),
|
||||
('egrep test.py test', output('test'), 'egrep test test.py'),
|
||||
('egrep -lir . test', output('test'), 'egrep -lir test .'),
|
||||
('egrep . test -lir', output('test'), 'egrep test -lir .')])
|
||||
def test_get_new_command(script, output, result):
|
||||
assert get_new_command(Command(script, output)) == result
|
||||
|
||||
Reference in New Issue
Block a user