1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-09-18 19:22:32 +01:00

#614: Add --repeat option

This commit is contained in:
Vladimir Iakovlev
2017-03-28 18:09:38 +02:00
parent c3eca8234a
commit cfa831c88d
15 changed files with 97 additions and 29 deletions

View File

@@ -3,29 +3,27 @@ from thefuck.argument_parser import Parser
from thefuck.const import ARGUMENT_PLACEHOLDER
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
@pytest.mark.parametrize('argv, result', [
(['thefuck'], {'alias': None, 'command': [], 'yes': False,
'help': False, 'version': False, 'debug': False}),
(['thefuck', '-a'],
{'alias': 'fuck', 'command': [], 'yes': False,
'help': False, 'version': False, 'debug': False}),
(['thefuck', '-a', 'fix'],
{'alias': 'fix', 'command': [], 'yes': False,
'help': False, 'version': False, 'debug': False}),
(['thefuck'], _args()),
(['thefuck', '-a'], _args(alias='fuck')),
(['thefuck', '-a', 'fix'], _args(alias='fix')),
(['thefuck', 'git', 'branch', ARGUMENT_PLACEHOLDER, '-y'],
{'alias': None, 'command': ['git', 'branch'], 'yes': True,
'help': False, 'version': False, 'debug': False}),
_args(command=['git', 'branch'], yes=True)),
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-y'],
{'alias': None, 'command': ['git', 'branch', '-a'], 'yes': True,
'help': False, 'version': False, 'debug': False}),
(['thefuck', ARGUMENT_PLACEHOLDER, '-v'],
{'alias': None, 'command': [], 'yes': False, 'help': False,
'version': True, 'debug': False}),
(['thefuck', ARGUMENT_PLACEHOLDER, '--help'],
{'alias': None, 'command': [], 'yes': False, 'help': True,
'version': False, 'debug': False}),
_args(command=['git', 'branch', '-a'], yes=True)),
(['thefuck', ARGUMENT_PLACEHOLDER, '-v'], _args(version=True)),
(['thefuck', ARGUMENT_PLACEHOLDER, '--help'], _args(help=True)),
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-y', '-d'],
{'alias': None, 'command': ['git', 'branch', '-a'], 'yes': True,
'help': False, 'version': False, 'debug': True})])
_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))])
def test_parse(argv, result):
assert vars(Parser().parse(argv)) == result