mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 04:21:14 +00:00
26 lines
729 B
Python
26 lines
729 B
Python
import pytest
|
|
from thefuck.rules.ag_literal import get_new_command, match
|
|
from thefuck.types import Command
|
|
|
|
|
|
@pytest.fixture
|
|
def output():
|
|
return ('ERR: Bad regex! pcre_compile() failed at position 1: missing )\n'
|
|
'If you meant to search for a literal string, run ag with -Q\n')
|
|
|
|
|
|
@pytest.mark.parametrize('script', ['ag \('])
|
|
def test_match(script, output):
|
|
assert match(Command(script, output))
|
|
|
|
|
|
@pytest.mark.parametrize('script', ['ag foo'])
|
|
def test_not_match(script):
|
|
assert not match(Command(script, ''))
|
|
|
|
|
|
@pytest.mark.parametrize('script, new_cmd', [
|
|
('ag \(', 'ag -Q \(')])
|
|
def test_get_new_command(script, new_cmd, output):
|
|
assert get_new_command((Command(script, output))) == new_cmd
|