diff --git a/tests/rules/test_git_commit_amend.py b/tests/rules/test_git_commit_amend.py index 743ccbf5..f364e4ea 100644 --- a/tests/rules/test_git_commit_amend.py +++ b/tests/rules/test_git_commit_amend.py @@ -3,18 +3,21 @@ from thefuck.rules.git_commit_amend import match, get_new_command from thefuck.types import Command -@pytest.mark.parametrize('script, output', [ - ('git commit -m "test"', 'test output'), - ('git commit', '')]) -def test_match(output, script): +@pytest.mark.parametrize('script, code, output', [ + ('git commit -m "test"', '0', 'test output'), + ('git commit', '0', '')]) +def test_match(monkeypatch, output, code, script): + monkeypatch.setenv('TF_STATUS', code) assert match(Command(script, output)) -@pytest.mark.parametrize('script', [ - 'git branch foo', - 'git checkout feature/test_commit', - 'git push']) -def test_not_match(script): +@pytest.mark.parametrize('script, code', [ + ('git branch foo', '0'), + ('git checkout feature/test_commit', '0'), + ('git push', '0'), + ('git commit -m', '1')]) +def test_not_match(monkeypatch, script, code): + monkeypatch.setenv('TF_STATUS', code) assert not match(Command(script, '')) diff --git a/tests/shells/test_fish.py b/tests/shells/test_fish.py index ff627a4e..4ead9668 100644 --- a/tests/shells/test_fish.py +++ b/tests/shells/test_fish.py @@ -81,7 +81,7 @@ class TestFish(object): assert 'function FUCK' in shell.app_alias('FUCK') assert 'thefuck' in shell.app_alias('fuck') assert 'TF_SHELL=fish' in shell.app_alias('fuck') - assert 'TF_ALIAS=fuck PYTHONIOENCODING' in shell.app_alias('fuck') + assert 'TF_ALIAS=fuck TF_STATUS=$status PYTHONIOENCODING' in shell.app_alias('fuck') assert 'PYTHONIOENCODING=utf-8 thefuck' in shell.app_alias('fuck') assert ARGUMENT_PLACEHOLDER in shell.app_alias('fuck') diff --git a/thefuck/types.py b/thefuck/types.py index a0c7b762..7019c758 100644 --- a/thefuck/types.py +++ b/thefuck/types.py @@ -25,7 +25,7 @@ class Command(object): @property def status_code(self): - return int(os.environ.get('TF_STATUS_CODE', 1)) + return int(os.environ.get('TF_STATUS', 1)) @property def stdout(self):