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

#253: Update default overridden aliases with user's

This commit is contained in:
Pablo Santiago Blum de Aguiar 2016-04-06 22:58:08 -03:00
parent 183b70c8b8
commit db6053b301
2 changed files with 14 additions and 12 deletions

View File

@ -19,14 +19,17 @@ class TestFish(object):
return mock
@pytest.fixture
def environ(self, monkeypatch):
data = {'TF_OVERRIDDEN_ALIASES': 'cd, ls, man, open'}
monkeypatch.setattr('thefuck.shells.fish.os.environ', data)
return data
def tf_overridden(self, monkeypatch, aliases):
monkeypatch.setattr('os.environ', {'TF_OVERRIDDEN_ALIASES': aliases})
@pytest.mark.usefixture('environ')
def test_get_overridden_aliases(self, shell, environ):
assert shell._get_overridden_aliases() == ['cd', 'ls', 'man', 'open']
@pytest.mark.parametrize('aliases', [
'cut,git,sed',
'cut, git, sed',
' cut,\tgit,sed\n',
'\ncut,\n\ngit,\tsed\r'])
def test_get_overridden_aliases(self, shell, tf_overridden):
assert shell._get_overridden_aliases() == {'cd', 'cut', 'git', 'grep',
'ls', 'man', 'open', 'sed'}
@pytest.mark.parametrize('before, after', [
('cd', 'cd'),

View File

@ -7,11 +7,10 @@ from .generic import Generic
class Fish(Generic):
def _get_overridden_aliases(self):
overridden_aliases = os.environ.get('TF_OVERRIDDEN_ALIASES', '').strip()
if overridden_aliases:
return [alias.strip() for alias in overridden_aliases.split(',')]
else:
return ['cd', 'grep', 'ls', 'man', 'open']
default = {'cd', 'grep', 'ls', 'man', 'open'}
for alias in os.environ.get('TF_OVERRIDDEN_ALIASES', '').split(','):
default.add(alias.strip())
return default
def app_alias(self, fuck):
# It is VERY important to have the variables declared WITHIN the alias