mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-19 00:58:56 +00:00
No need to use complicated indirect fixtures
This commit is contained in:
parent
7b5e703f50
commit
f0c6893eaa
@ -3,33 +3,33 @@ from thefuck.rules.git_push import match, get_new_command
|
|||||||
from thefuck.types import Command
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture
|
||||||
def output(request):
|
def output(branch_name):
|
||||||
if not request.param:
|
if not branch_name:
|
||||||
return ''
|
return ''
|
||||||
return '''fatal: The current branch {} has no upstream branch.
|
return '''fatal: The current branch {} has no upstream branch.
|
||||||
To push the current branch and set the remote as upstream, use
|
To push the current branch and set the remote as upstream, use
|
||||||
|
|
||||||
git push --set-upstream origin {}
|
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', 'master'),
|
||||||
('git push origin', 'master')], indirect=['output'])
|
('git push origin', 'master')])
|
||||||
def test_match(script, output):
|
def test_match(output, script, branch_name):
|
||||||
assert match(Command(script, output))
|
assert match(Command(script, output))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('script, output', [
|
@pytest.mark.parametrize('script, branch_name', [
|
||||||
('git push master', None),
|
('git push master', None),
|
||||||
('ls', 'master')], indirect=['output'])
|
('ls', 'master')])
|
||||||
def test_not_match(script, output):
|
def test_not_match(output, script, branch_name):
|
||||||
assert not match(Command(script, output))
|
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 master', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
('git push master', '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 --quiet origin', 'master',
|
||||||
'git -c test=test push --set-upstream origin master --quiet'),
|
'git -c test=test push --set-upstream origin master --quiet'),
|
||||||
('git push', "test's",
|
('git push', "test's",
|
||||||
"git push --set-upstream origin test\\'s")], indirect=['output'])
|
"git push --set-upstream origin test\\'s")])
|
||||||
def test_get_new_command(script, output, new_command):
|
def test_get_new_command(output, script, branch_name, new_command):
|
||||||
assert get_new_command(Command(script, output)) == new_command
|
assert get_new_command(Command(script, output)) == new_command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user