From aec8fe32337e2721d198b78f0a8a37d8161d5da8 Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Tue, 8 Nov 2016 23:53:40 +0100 Subject: [PATCH] #570: Refine tests --- tests/rules/test_git_flag_after_filename.py | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/rules/test_git_flag_after_filename.py b/tests/rules/test_git_flag_after_filename.py index b81668b0..4cf49957 100644 --- a/tests/rules/test_git_flag_after_filename.py +++ b/tests/rules/test_git_flag_after_filename.py @@ -1,3 +1,4 @@ +import pytest from thefuck.rules.git_flag_after_filename import match, get_new_command from tests.utils import Command @@ -9,15 +10,22 @@ command3 = Command('git log -p README.md --name-only', stderr="fatal: bad flag '--name-only' used after filename") -def test_match(): - assert match(command1) - assert match(command2) - assert match(command3) - assert not match(Command('git log README.md')) - assert not match(Command('git log -p README.md')) +@pytest.mark.parametrize('command', [ + command1, command2, command3]) +def test_match(command): + assert match(command) -def test_get_new_command(): - assert get_new_command(command1) == "git log -p README.md" - assert get_new_command(command2) == "git log -p README.md CONTRIBUTING.md" - assert get_new_command(command3) == "git log -p --name-only README.md" +@pytest.mark.parametrize('command', [ + Command('git log README.md'), + Command('git log -p README.md')]) +def test_not_match(command): + assert not match(command) + + +@pytest.mark.parametrize('command, result', [ + (command1, "git log -p README.md"), + (command2, "git log -p README.md CONTRIBUTING.md"), + (command3, "git log -p --name-only README.md")]) +def test_get_new_command(command, result): + assert get_new_command(command) == result