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

No need to use complicated indirect fixtures

This commit is contained in:
David 2018-01-03 21:54:18 +00:00
parent 7b5e703f50
commit f0c6893eaa

View File

@ -3,33 +3,33 @@ from thefuck.rules.git_push import match, get_new_command
from thefuck.types import Command
@pytest.fixture(scope='function')
def output(request):
if not request.param:
@pytest.fixture
def output(branch_name):
if not branch_name:
return ''
return '''fatal: The current branch {} has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin {}
'''.format(request.param, request.param)
'''.format(branch_name, branch_name)
@pytest.mark.parametrize('script, output', [
@pytest.mark.parametrize('script, branch_name', [
('git push', 'master'),
('git push origin', 'master')], indirect=['output'])
def test_match(script, output):
('git push origin', 'master')])
def test_match(output, script, branch_name):
assert match(Command(script, output))
@pytest.mark.parametrize('script, output', [
@pytest.mark.parametrize('script, branch_name', [
('git push master', None),
('ls', 'master')], indirect=['output'])
def test_not_match(script, output):
('ls', 'master')])
def test_not_match(output, script, branch_name):
assert not match(Command(script, output))
@pytest.mark.parametrize('script, output, new_command', [
@pytest.mark.parametrize('script, branch_name, new_command', [
('git push master', 'master',
'git push --set-upstream origin master'),
('git push master', 'master',
@ -51,6 +51,6 @@ def test_not_match(script, output):
('git -c test=test push --quiet origin', 'master',
'git -c test=test push --set-upstream origin master --quiet'),
('git push', "test's",
"git push --set-upstream origin test\\'s")], indirect=['output'])
def test_get_new_command(script, output, new_command):
"git push --set-upstream origin test\\'s")])
def test_get_new_command(output, script, branch_name, new_command):
assert get_new_command(Command(script, output)) == new_command