1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-14 06:38:32 +00:00

Fix tests

This commit is contained in:
David 2020-03-24 10:46:35 +00:00
parent 4432ed21c6
commit 59d0836b6f
3 changed files with 14 additions and 11 deletions

View File

@ -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, ''))

View File

@ -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')

View File

@ -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):