From 54c408a6b572e84f75b1f11133d6769a6aef3dab Mon Sep 17 00:00:00 2001 From: nvbn Date: Wed, 22 Apr 2015 22:37:11 +0200 Subject: [PATCH] Rename `DEFAULT` to `DEFAULT_RULES` --- README.md | 4 ++-- tests/test_conf.py | 14 +++++++------- tests/test_main.py | 2 +- thefuck/conf.py | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 650ea8d7..8b98fec2 100644 --- a/README.md +++ b/README.md @@ -196,14 +196,14 @@ def get_new_command(command, settings): The Fuck has a few settings parameters, they can be changed in `~/.thefuck/settings.py`: -* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT`; +* `rules` – list of enabled rules, by default `thefuck.conf.DEFAULT_RULES`; * `require_confirmation` – require confirmation before running new command, by default `False`; * `wait_command` – max amount of time in seconds for getting previous command output; * `no_colors` – disable colored output. Or via environment variables: -* `THEFUCK_RULES` – list of enabled rules, like `DEFAULT:rm_root` or `sudo:no_command`; +* `THEFUCK_RULES` – list of enabled rules, like `DEFAULT_RULES:rm_root` or `sudo:no_command`; * `THEFUCK_REQUIRE_CONFIRMATION` – require confirmation before running new command, `true/false`; * `THEFUCK_WAIT_COMMAND` – max amount of time in seconds for getting previous command output; * `THEFUCK_NO_COLORS` – disable colored output, `true/false`. diff --git a/tests/test_conf.py b/tests/test_conf.py index 929a41e1..f25e9f5e 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -11,9 +11,9 @@ def test_rules_names_list(): def test_default(): - assert Rule('test', None, None, True) in conf.DEFAULT - assert Rule('test', None, None, False) not in conf.DEFAULT - assert Rule('test', None, None, False) in (conf.DEFAULT + ['test']) + assert Rule('test', None, None, True) in conf.DEFAULT_RULES + assert Rule('test', None, None, False) not in conf.DEFAULT_RULES + assert Rule('test', None, None, False) in (conf.DEFAULT_RULES + ['test']) def test_settings_defaults(): @@ -37,13 +37,13 @@ def test_settings_from_file(): def test_settings_from_file_with_DEFAULT(): - with patch('thefuck.conf.load_source', return_value=Mock(rules=conf.DEFAULT + ['test'], + with patch('thefuck.conf.load_source', return_value=Mock(rules=conf.DEFAULT_RULES + ['test'], wait_command=10, require_confirmation=True, no_colors=True)), \ patch('thefuck.conf.os.environ', new_callable=lambda: {}): settings = conf.get_settings(Mock()) - assert settings.rules == conf.DEFAULT + ['test'] + assert settings.rules == conf.DEFAULT_RULES + ['test'] def test_settings_from_env(): @@ -63,9 +63,9 @@ def test_settings_from_env(): def test_settings_from_env_with_DEFAULT(): with patch('thefuck.conf.load_source', return_value=Mock()), \ - patch('thefuck.conf.os.environ', new_callable=lambda: {'THEFUCK_RULES': 'DEFAULT:bash:lisp'}): + patch('thefuck.conf.os.environ', new_callable=lambda: {'THEFUCK_RULES': 'DEFAULT_RULES:bash:lisp'}): settings = conf.get_settings(Mock()) - assert settings.rules == conf.DEFAULT + ['bash', 'lisp'] + assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp'] def test_update_settings(): diff --git a/tests/test_main.py b/tests/test_main.py index aacc17d4..19e460cd 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -25,7 +25,7 @@ def test_get_rules(): glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')] assert list(main.get_rules( Path('~'), - Mock(rules=conf.DEFAULT))) \ + Mock(rules=conf.DEFAULT_RULES))) \ == [main.Rule('bash', 'bash', 'bash', True), main.Rule('lisp', 'lisp', 'lisp', True), main.Rule('bash', 'bash', 'bash', True), diff --git a/thefuck/conf.py b/thefuck/conf.py index 6c2b8947..2da0f5c6 100644 --- a/thefuck/conf.py +++ b/thefuck/conf.py @@ -28,7 +28,7 @@ class _DefaultRulesNames(RulesNamesList): return False -DEFAULT = _DefaultRulesNames([]) +DEFAULT_RULES = _DefaultRulesNames([]) class Settings(object): @@ -45,7 +45,7 @@ class Settings(object): return Settings(conf) -DEFAULT_SETTINGS = {'rules': DEFAULT, +DEFAULT_SETTINGS = {'rules': DEFAULT_RULES, 'wait_command': 3, 'require_confirmation': False, 'no_colors': False} @@ -68,8 +68,8 @@ def _settings_from_file(user_dir): def _rules_from_env(val): """Transforms rules list from env-string to python.""" val = val.split(':') - if 'DEFAULT' in val: - val = DEFAULT + [rule for rule in val if rule != 'DEFAULT'] + if 'DEFAULT_RULES' in val: + val = DEFAULT_RULES + [rule for rule in val if rule != 'DEFAULT_RULES'] return val