From 5b3350b2dd4ee2789575355ef3c6d7ace893cdd3 Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Wed, 21 Nov 2018 19:43:01 +0100 Subject: [PATCH] #N/A: Fix tests with py.test 4 --- tests/rules/test_git_checkout.py | 1 - tests/rules/test_git_merge.py | 14 ++++++-------- tests/rules/test_git_merge_unrelated.py | 12 +++++------- tests/rules/test_touch.py | 10 ++++------ 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/tests/rules/test_git_checkout.py b/tests/rules/test_git_checkout.py index a803f201..20fff03c 100644 --- a/tests/rules/test_git_checkout.py +++ b/tests/rules/test_git_checkout.py @@ -4,7 +4,6 @@ from thefuck.rules.git_checkout import match, get_branches, get_new_command from thefuck.types import Command -@pytest.fixture def did_not_match(target, did_you_forget=False): error = ("error: pathspec '{}' did not match any " "file(s) known to git.".format(target)) diff --git a/tests/rules/test_git_merge.py b/tests/rules/test_git_merge.py index c347a59f..0829d282 100644 --- a/tests/rules/test_git_merge.py +++ b/tests/rules/test_git_merge.py @@ -3,24 +3,22 @@ from thefuck.rules.git_merge import match, get_new_command from thefuck.types import Command -@pytest.fixture -def output(): - return 'merge: local - not something we can merge\n\n' \ - 'Did you mean this?\n\tremote/local' +output = 'merge: local - not something we can merge\n\n' \ + 'Did you mean this?\n\tremote/local' -def test_match(output): +def test_match(): assert match(Command('git merge test', output)) assert not match(Command('git merge master', '')) assert not match(Command('ls', output)) @pytest.mark.parametrize('command, new_command', [ - (Command('git merge local', output()), + (Command('git merge local', output), 'git merge remote/local'), - (Command('git merge -m "test" local', output()), + (Command('git merge -m "test" local', output), 'git merge -m "test" remote/local'), - (Command('git merge -m "test local" local', output()), + (Command('git merge -m "test local" local', output), 'git merge -m "test local" remote/local')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command diff --git a/tests/rules/test_git_merge_unrelated.py b/tests/rules/test_git_merge_unrelated.py index c9a2b9ed..dee0f97e 100644 --- a/tests/rules/test_git_merge_unrelated.py +++ b/tests/rules/test_git_merge_unrelated.py @@ -3,23 +3,21 @@ from thefuck.rules.git_merge_unrelated import match, get_new_command from thefuck.types import Command -@pytest.fixture -def output(): - return 'fatal: refusing to merge unrelated histories' +output = 'fatal: refusing to merge unrelated histories' -def test_match(output): +def test_match(): assert match(Command('git merge test', output)) assert not match(Command('git merge master', '')) assert not match(Command('ls', output)) @pytest.mark.parametrize('command, new_command', [ - (Command('git merge local', output()), + (Command('git merge local', output), 'git merge local --allow-unrelated-histories'), - (Command('git merge -m "test" local', output()), + (Command('git merge -m "test" local', output), 'git merge -m "test" local --allow-unrelated-histories'), - (Command('git merge -m "test local" local', output()), + (Command('git merge -m "test local" local', output), 'git merge -m "test local" local --allow-unrelated-histories')]) def test_get_new_command(command, new_command): assert get_new_command(command) == new_command diff --git a/tests/rules/test_touch.py b/tests/rules/test_touch.py index 8201fe02..0438b254 100644 --- a/tests/rules/test_touch.py +++ b/tests/rules/test_touch.py @@ -3,9 +3,7 @@ from thefuck.rules.touch import match, get_new_command from thefuck.types import Command -@pytest.fixture def output(is_bsd): - print(is_bsd) if is_bsd: return "touch: /a/b/c: No such file or directory" return "touch: cannot touch '/a/b/c': No such file or directory" @@ -14,8 +12,8 @@ def output(is_bsd): @pytest.mark.parametrize('script, is_bsd', [ ('touch /a/b/c', False), ('touch /a/b/c', True)]) -def test_match(script, is_bsd, output): - command = Command(script, output) +def test_match(script, is_bsd): + command = Command(script, output(is_bsd)) assert match(command) @@ -29,7 +27,7 @@ def test_not_match(command): @pytest.mark.parametrize('script, is_bsd', [ ('touch /a/b/c', False), ('touch /a/b/c', True)]) -def test_get_new_command(script, is_bsd, output): - command = Command(script, output) +def test_get_new_command(script, is_bsd): + command = Command(script, output(is_bsd)) fixed_command = get_new_command(command) assert fixed_command == 'mkdir -p /a/b && touch /a/b/c'