2015-07-04 16:45:30 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.rules.sed_unterminated_s import match, get_new_command
|
2017-08-31 17:58:56 +02:00
|
|
|
from thefuck.types import Command
|
2015-07-04 16:45:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def sed_unterminated_s():
|
|
|
|
return "sed: -e expression #1, char 9: unterminated `s' command"
|
|
|
|
|
|
|
|
|
|
|
|
def test_match(sed_unterminated_s):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert match(Command('sed -e s/foo/bar', sed_unterminated_s))
|
|
|
|
assert match(Command('sed -es/foo/bar', sed_unterminated_s))
|
|
|
|
assert match(Command('sed -e s/foo/bar -e s/baz/quz', sed_unterminated_s))
|
|
|
|
assert not match(Command('sed -e s/foo/bar', ''))
|
|
|
|
assert not match(Command('sed -es/foo/bar', ''))
|
|
|
|
assert not match(Command('sed -e s/foo/bar -e s/baz/quz', ''))
|
2015-07-04 16:45:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_get_new_command(sed_unterminated_s):
|
2017-08-31 17:58:56 +02:00
|
|
|
assert (get_new_command(Command('sed -e s/foo/bar', sed_unterminated_s))
|
2016-10-06 14:51:22 -04:00
|
|
|
== 'sed -e s/foo/bar/')
|
2017-08-31 17:58:56 +02:00
|
|
|
assert (get_new_command(Command('sed -es/foo/bar', sed_unterminated_s))
|
2016-10-06 14:51:22 -04:00
|
|
|
== 'sed -es/foo/bar/')
|
2017-08-31 17:58:56 +02:00
|
|
|
assert (get_new_command(Command(r"sed -e 's/\/foo/bar'", sed_unterminated_s))
|
2016-10-06 14:51:22 -04:00
|
|
|
== r"sed -e 's/\/foo/bar/'")
|
2017-08-31 17:58:56 +02:00
|
|
|
assert (get_new_command(Command(r"sed -e s/foo/bar -es/baz/quz", sed_unterminated_s))
|
2016-10-06 14:51:22 -04:00
|
|
|
== r"sed -e s/foo/bar/ -es/baz/quz/")
|