2017-03-28 11:31:06 +02:00
|
|
|
import pytest
|
|
|
|
from thefuck.argument_parser import Parser
|
|
|
|
from thefuck.const import ARGUMENT_PLACEHOLDER
|
|
|
|
|
|
|
|
|
2017-03-28 18:09:38 +02:00
|
|
|
def _args(**override):
|
|
|
|
args = {'alias': None, 'command': [], 'yes': False,
|
|
|
|
'help': False, 'version': False, 'debug': False,
|
|
|
|
'force_command': None, 'repeat': False}
|
|
|
|
args.update(override)
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
2017-03-28 11:31:06 +02:00
|
|
|
@pytest.mark.parametrize('argv, result', [
|
2017-03-28 18:09:38 +02:00
|
|
|
(['thefuck'], _args()),
|
|
|
|
(['thefuck', '-a'], _args(alias='fuck')),
|
|
|
|
(['thefuck', '-a', 'fix'], _args(alias='fix')),
|
2017-03-28 11:31:06 +02:00
|
|
|
(['thefuck', 'git', 'branch', ARGUMENT_PLACEHOLDER, '-y'],
|
2017-03-28 18:09:38 +02:00
|
|
|
_args(command=['git', 'branch'], yes=True)),
|
2017-03-28 11:31:06 +02:00
|
|
|
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-y'],
|
2017-03-28 18:09:38 +02:00
|
|
|
_args(command=['git', 'branch', '-a'], yes=True)),
|
|
|
|
(['thefuck', ARGUMENT_PLACEHOLDER, '-v'], _args(version=True)),
|
|
|
|
(['thefuck', ARGUMENT_PLACEHOLDER, '--help'], _args(help=True)),
|
2017-03-28 13:09:11 +02:00
|
|
|
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-y', '-d'],
|
2017-03-28 18:09:38 +02:00
|
|
|
_args(command=['git', 'branch', '-a'], yes=True, debug=True)),
|
|
|
|
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-r', '-d'],
|
|
|
|
_args(command=['git', 'branch', '-a'], repeat=True, debug=True))])
|
2017-03-28 11:31:06 +02:00
|
|
|
def test_parse(argv, result):
|
|
|
|
assert vars(Parser().parse(argv)) == result
|