#N/A: Move all consts to const
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from thefuck import shells
|
||||
from thefuck import conf
|
||||
from thefuck import conf, const
|
||||
|
||||
shells.shell = shells.Generic()
|
||||
|
||||
@@ -22,7 +22,7 @@ def no_memoize(monkeypatch):
|
||||
def settings(request):
|
||||
def _reset_settings():
|
||||
conf.settings.clear()
|
||||
conf.settings.update(conf.DEFAULT_SETTINGS)
|
||||
conf.settings.update(const.DEFAULT_SETTINGS)
|
||||
|
||||
request.addfinalizer(_reset_settings)
|
||||
conf.settings.user_dir = Path('~/.thefuck')
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
import six
|
||||
from mock import Mock
|
||||
from thefuck import conf
|
||||
from thefuck import const
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -20,7 +20,7 @@ def environ(monkeypatch):
|
||||
def test_settings_defaults(load_source, settings):
|
||||
load_source.return_value = object()
|
||||
settings.init()
|
||||
for key, val in conf.DEFAULT_SETTINGS.items():
|
||||
for key, val in const.DEFAULT_SETTINGS.items():
|
||||
assert getattr(settings, key) == val
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ class TestSettingsFromFile(object):
|
||||
assert settings.exclude_rules == ['git']
|
||||
|
||||
def test_from_file_with_DEFAULT(self, load_source, settings):
|
||||
load_source.return_value = Mock(rules=conf.DEFAULT_RULES + ['test'],
|
||||
load_source.return_value = Mock(rules=const.DEFAULT_RULES + ['test'],
|
||||
wait_command=10,
|
||||
exclude_rules=[],
|
||||
require_confirmation=True,
|
||||
no_colors=True)
|
||||
settings.init()
|
||||
assert settings.rules == conf.DEFAULT_RULES + ['test']
|
||||
assert settings.rules == const.DEFAULT_RULES + ['test']
|
||||
|
||||
|
||||
@pytest.mark.usefixture('load_source')
|
||||
@@ -71,7 +71,7 @@ class TestSettingsFromEnv(object):
|
||||
def test_from_env_with_DEFAULT(self, environ, settings):
|
||||
environ.update({'THEFUCK_RULES': 'DEFAULT_RULES:bash:lisp'})
|
||||
settings.init()
|
||||
assert settings.rules == conf.DEFAULT_RULES + ['bash', 'lisp']
|
||||
assert settings.rules == const.DEFAULT_RULES + ['bash', 'lisp']
|
||||
|
||||
|
||||
class TestInitializeSettingsFile(object):
|
||||
@@ -93,7 +93,7 @@ class TestInitializeSettingsFile(object):
|
||||
settings_file_contents = settings_file.getvalue()
|
||||
assert settings_path_mock.is_file.call_count == 1
|
||||
assert settings_path_mock.open.call_count == 1
|
||||
assert conf.SETTINGS_HEADER in settings_file_contents
|
||||
for setting in conf.DEFAULT_SETTINGS.items():
|
||||
assert const.SETTINGS_HEADER in settings_file_contents
|
||||
for setting in const.DEFAULT_SETTINGS.items():
|
||||
assert '# {} = {}\n'.format(*setting) in settings_file_contents
|
||||
settings_file.close()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import pytest
|
||||
from pathlib import PosixPath
|
||||
from thefuck import corrector, conf
|
||||
from thefuck import corrector, const
|
||||
from tests.utils import Rule, Command, CorrectedCommand
|
||||
from thefuck.corrector import get_corrected_commands, organize_commands
|
||||
|
||||
@@ -24,9 +24,9 @@ class TestGetRules(object):
|
||||
assert {r.name for r in rules} == set(names)
|
||||
|
||||
@pytest.mark.parametrize('paths, conf_rules, exclude_rules, loaded_rules', [
|
||||
(['git.py', 'bash.py'], conf.DEFAULT_RULES, [], ['git', 'bash']),
|
||||
(['git.py', 'bash.py'], const.DEFAULT_RULES, [], ['git', 'bash']),
|
||||
(['git.py', 'bash.py'], ['git'], [], ['git']),
|
||||
(['git.py', 'bash.py'], conf.DEFAULT_RULES, ['git'], ['bash']),
|
||||
(['git.py', 'bash.py'], const.DEFAULT_RULES, ['git'], ['bash']),
|
||||
(['git.py', 'bash.py'], ['git'], ['git'], [])])
|
||||
def test_get_rules(self, glob, settings, paths, conf_rules, exclude_rules,
|
||||
loaded_rules):
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@ from mock import Mock
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from tests.utils import CorrectedCommand, Rule, Command
|
||||
from thefuck import conf
|
||||
from thefuck import const
|
||||
from thefuck.exceptions import EmptyCommand
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ class TestRule(object):
|
||||
load_source.assert_called_once_with('bash', '/rules/bash.py')
|
||||
|
||||
@pytest.mark.parametrize('rules, exclude_rules, rule, is_enabled', [
|
||||
(conf.DEFAULT_RULES, [], Rule('git', enabled_by_default=True), True),
|
||||
(conf.DEFAULT_RULES, [], Rule('git', enabled_by_default=False), False),
|
||||
(const.DEFAULT_RULES, [], Rule('git', enabled_by_default=True), True),
|
||||
(const.DEFAULT_RULES, [], Rule('git', enabled_by_default=False), False),
|
||||
([], [], Rule('git', enabled_by_default=False), False),
|
||||
([], [], Rule('git', enabled_by_default=True), False),
|
||||
(conf.DEFAULT_RULES + ['git'], [], Rule('git', enabled_by_default=False), True),
|
||||
(const.DEFAULT_RULES + ['git'], [], Rule('git', enabled_by_default=False), True),
|
||||
(['git'], [], Rule('git', enabled_by_default=False), True),
|
||||
(conf.DEFAULT_RULES, ['git'], Rule('git', enabled_by_default=True), False),
|
||||
(conf.DEFAULT_RULES, ['git'], Rule('git', enabled_by_default=False), False),
|
||||
(const.DEFAULT_RULES, ['git'], Rule('git', enabled_by_default=True), False),
|
||||
(const.DEFAULT_RULES, ['git'], Rule('git', enabled_by_default=False), False),
|
||||
([], ['git'], Rule('git', enabled_by_default=True), False),
|
||||
([], ['git'], Rule('git', enabled_by_default=False), False)])
|
||||
def test_is_enabled(self, settings, rules, exclude_rules, rule, is_enabled):
|
||||
|
||||
+3
-1
@@ -31,7 +31,9 @@ def test_read_actions(patch_get_key):
|
||||
# Ctrl+C:
|
||||
const.KEY_CTRL_C])
|
||||
assert list(islice(ui.read_actions(), 5)) \
|
||||
== [ui.SELECT, ui.SELECT, ui.PREVIOUS, ui.NEXT, ui.ABORT]
|
||||
== [const.ACTION_SELECT, const.ACTION_SELECT,
|
||||
const.ACTION_PREVIOUS, const.ACTION_NEXT,
|
||||
const.ACTION_ABORT]
|
||||
|
||||
|
||||
def test_command_selector():
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
from thefuck import types
|
||||
from thefuck.conf import DEFAULT_PRIORITY
|
||||
from thefuck.const import DEFAULT_PRIORITY
|
||||
|
||||
|
||||
class Command(types.Command):
|
||||
|
||||
Reference in New Issue
Block a user