1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-06 02:41:10 +01:00

test_git_flag_after_filename.py: dedupe test commands

This commit is contained in:
Joseph Frazier 2016-10-31 00:15:21 -04:00
parent 9cae0bffff
commit fa169c686c

View File

@ -1,19 +1,23 @@
from thefuck.rules.git_flag_after_filename import match, get_new_command from thefuck.rules.git_flag_after_filename import match, get_new_command
from tests.utils import Command from tests.utils import Command
command1 = Command('git log README.md -p',
stderr="fatal: bad flag '-p' used after filename")
command2 = Command('git log README.md -p CONTRIBUTING.md',
stderr="fatal: bad flag '-p' used after filename")
command3 = Command('git log -p README.md --name-only',
stderr="fatal: bad flag '--name-only' used after filename")
def test_match(): def test_match():
assert match(Command('git log README.md -p', stderr="fatal: bad flag '-p' used after filename")) assert match(command1)
assert match(Command('git log README.md -p CONTRIBUTING.md', stderr="fatal: bad flag '-p' used after filename")) assert match(command2)
assert match(Command('git log -p README.md --name-only', stderr="fatal: bad flag '--name-only' used after filename")) assert match(command3)
assert not match(Command('git log README.md')) assert not match(Command('git log README.md'))
assert not match(Command('git log -p README.md')) assert not match(Command('git log -p README.md'))
def test_get_new_command(): def test_get_new_command():
assert get_new_command(Command('git log README.md -p', stderr="fatal: bad flag '-p' used after filename"))\ assert get_new_command(command1) == "git log -p README.md"
== "git log -p README.md" assert get_new_command(command2) == "git log -p README.md CONTRIBUTING.md"
assert get_new_command(Command('git log README.md -p CONTRIBUTING.md', stderr="fatal: bad flag '-p' used after filename"))\ assert get_new_command(command3) == "git log -p --name-only README.md"
== "git log -p README.md CONTRIBUTING.md"
assert get_new_command(Command('git log -p README.md --name-only', stderr="fatal: bad flag '--name-only' used after filename"))\
== "git log -p --name-only README.md"