mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 17:48:41 +00:00
Use output as test fixture
This commit is contained in:
parent
85e240e7d1
commit
3c0cba290c
@ -3,52 +3,55 @@ from thefuck.rules.git_push import match, get_new_command
|
|||||||
from thefuck.types import Command
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture(scope='function')
|
||||||
def output(branch):
|
def output(request):
|
||||||
|
if not request.param:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
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(branch, branch)
|
'''.format(request.param, request.param)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('script, output', [
|
||||||
Command('git push', output('master')),
|
('git push', 'master'),
|
||||||
Command('git push master', output('master'))])
|
('git push origin', 'master')], indirect=['output'])
|
||||||
def test_match(command):
|
def test_match(script, output):
|
||||||
assert match(command)
|
assert match(Command(script, output))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command', [
|
@pytest.mark.parametrize('script, output', [
|
||||||
Command('git push master', ''),
|
('git push master', None),
|
||||||
Command('ls', output('master'))])
|
('ls', 'master')], indirect=['output'])
|
||||||
def test_not_match(command):
|
def test_not_match(script, output):
|
||||||
assert not match(command)
|
assert not match(Command(script, output))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('command, new_command', [
|
@pytest.mark.parametrize('script, output, new_command', [
|
||||||
(Command('git push master', output('master')),
|
('git push master', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push master', output('master')),
|
('git push master', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push master', output('master')),
|
('git push master', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push -u', output('master')),
|
('git push -u', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push -u origin', output('master')),
|
('git push -u origin', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push origin', output('master')),
|
('git push origin', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push --set-upstream origin', output('master')),
|
('git push --set-upstream origin', 'master',
|
||||||
'git push --set-upstream origin master'),
|
'git push --set-upstream origin master'),
|
||||||
(Command('git push --quiet', output('master')),
|
('git push --quiet', 'master',
|
||||||
'git push --set-upstream origin master --quiet'),
|
'git push --set-upstream origin master --quiet'),
|
||||||
(Command('git push --quiet origin', output('master')),
|
('git push --quiet origin', 'master',
|
||||||
'git push --set-upstream origin master --quiet'),
|
'git push --set-upstream origin master --quiet'),
|
||||||
(Command('git -c test=test push --quiet origin', output('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'),
|
||||||
(Command('git push', output("test's")),
|
('git push', "test's",
|
||||||
"git push --set-upstream origin test\\'s")])
|
"git push --set-upstream origin test\\'s")], indirect=['output'])
|
||||||
def test_get_new_command(command, new_command):
|
def test_get_new_command(script, output, new_command):
|
||||||
assert get_new_command(command) == new_command
|
assert get_new_command(Command(script, output)) == new_command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user