1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-10-31 23:22:10 +00:00

#620: Add support of arguments to fuck, like fuck -y on zsh

This commit is contained in:
Vladimir Iakovlev
2017-03-28 11:31:06 +02:00
parent d28567bb31
commit ec37998a10
8 changed files with 129 additions and 49 deletions

View File

@@ -40,17 +40,17 @@ class TestZsh(object):
'll': 'ls -alF'}
def test_app_alias(self, shell):
assert 'alias fuck' in shell.app_alias('fuck')
assert 'alias FUCK' in shell.app_alias('FUCK')
assert 'fuck () {' in shell.app_alias('fuck')
assert 'FUCK () {' in shell.app_alias('FUCK')
assert 'thefuck' in shell.app_alias('fuck')
assert 'PYTHONIOENCODING' in shell.app_alias('fuck')
def test_app_alias_variables_correctly_set(self, shell):
alias = shell.app_alias('fuck')
assert "alias fuck='TF_CMD=$(TF_ALIAS" in alias
assert '$(TF_ALIAS=fuck PYTHONIOENCODING' in alias
assert 'PYTHONIOENCODING=utf-8 TF_SHELL_ALIASES' in alias
assert 'ALIASES=$(alias) thefuck' in alias
assert "fuck () {" in alias
assert "TF_ALIAS=fuck" in alias
assert 'PYTHONIOENCODING=utf-8' in alias
assert 'TF_SHELL_ALIASES=$(alias)' in alias
def test_get_history(self, history_lines, shell):
history_lines([': 1432613911:0;ls', ': 1432613916:0;rm'])

View File

@@ -0,0 +1,26 @@
import pytest
from thefuck.argument_parser import Parser
from thefuck.const import ARGUMENT_PLACEHOLDER
@pytest.mark.parametrize('argv, result', [
(['thefuck'], {'alias': None, 'command': [], 'yes': False,
'help': False, 'version': False}),
(['thefuck', '-a'], {'alias': 'fuck', 'command': [], 'yes': False,
'help': False, 'version': False}),
(['thefuck', '-a', 'fix'], {'alias': 'fix', 'command': [], 'yes': False,
'help': False, 'version': False}),
(['thefuck', 'git', 'branch', ARGUMENT_PLACEHOLDER, '-y'],
{'alias': None, 'command': ['git', 'branch'], 'yes': True,
'help': False, 'version': False}),
(['thefuck', 'git', 'branch', '-a', ARGUMENT_PLACEHOLDER, '-y'],
{'alias': None, 'command': ['git', 'branch', '-a'], 'yes': True,
'help': False, 'version': False}),
(['thefuck', ARGUMENT_PLACEHOLDER, '-v'],
{'alias': None, 'command': [], 'yes': False, 'help': False,
'version': True}),
(['thefuck', ARGUMENT_PLACEHOLDER, '--help'],
{'alias': None, 'command': [], 'yes': False, 'help': True,
'version': False})])
def test_parse(argv, result):
assert vars(Parser().parse(argv)) == result