mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-19 03:32:31 +01:00
⚠️ Remove settings
param from rules match
, get_new_command
and side_effect
This commit is contained in:
@@ -3,8 +3,7 @@ from mock import Mock
|
||||
import six
|
||||
from thefuck.utils import default_settings, \
|
||||
memoize, get_closest, get_all_executables, replace_argument, \
|
||||
get_all_matched_commands, is_app, for_app, cache
|
||||
from thefuck.types import Settings
|
||||
get_all_matched_commands, is_app, for_app, cache, compatibility_call
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
@@ -12,9 +11,12 @@ from tests.utils import Command
|
||||
({'key': 'val'}, {}, {'key': 'val'}),
|
||||
({'key': 'new-val'}, {'key': 'val'}, {'key': 'val'}),
|
||||
({'key': 'new-val', 'unset': 'unset'}, {'key': 'val'}, {'key': 'val', 'unset': 'unset'})])
|
||||
def test_default_settings(override, old, new):
|
||||
fn = lambda _, settings: settings
|
||||
assert default_settings(override)(fn)(None, Settings(old)) == new
|
||||
def test_default_settings(settings, override, old, new):
|
||||
settings.clear()
|
||||
settings.update(old)
|
||||
fn = lambda _: _
|
||||
default_settings(override)(fn)(None)
|
||||
assert settings == new
|
||||
|
||||
|
||||
def test_memoize():
|
||||
@@ -112,10 +114,10 @@ def test_is_app(script, names, result):
|
||||
('hg diff', ['git', 'hub'], False)])
|
||||
def test_for_app(script, names, result):
|
||||
@for_app(*names)
|
||||
def match(command, settings):
|
||||
def match(command):
|
||||
return True
|
||||
|
||||
assert match(Command(script), None) == result
|
||||
assert match(Command(script)) == result
|
||||
|
||||
|
||||
class TestCache(object):
|
||||
@@ -180,3 +182,50 @@ class TestCache(object):
|
||||
shelve.update({key: {'etag': '-1', 'value': 'old-value'}})
|
||||
assert fn() == 'test'
|
||||
assert shelve == {key: {'etag': '0', 'value': 'test'}}
|
||||
|
||||
|
||||
class TestCompatibilityCall(object):
|
||||
def test_match(self):
|
||||
def match(command):
|
||||
assert command == Command()
|
||||
return True
|
||||
|
||||
assert compatibility_call(match, Command())
|
||||
|
||||
def test_old_match(self, settings):
|
||||
def match(command, _settings):
|
||||
assert command == Command()
|
||||
assert settings == _settings
|
||||
return True
|
||||
|
||||
assert compatibility_call(match, Command())
|
||||
|
||||
def test_get_new_command(self):
|
||||
def get_new_command(command):
|
||||
assert command == Command()
|
||||
return True
|
||||
|
||||
assert compatibility_call(get_new_command, Command())
|
||||
|
||||
def test_old_get_new_command(self, settings):
|
||||
def get_new_command(command, _settings):
|
||||
assert command == Command()
|
||||
assert settings == _settings
|
||||
return True
|
||||
|
||||
assert compatibility_call(get_new_command, Command())
|
||||
|
||||
def test_side_effect(self):
|
||||
def side_effect(command, new_command):
|
||||
assert command == Command() == new_command
|
||||
return True
|
||||
|
||||
assert compatibility_call(side_effect, Command(), Command())
|
||||
|
||||
def test_old_side_effect(self, settings):
|
||||
def side_effect(command, new_command, _settings):
|
||||
assert command == Command() == new_command
|
||||
assert settings == _settings
|
||||
return True
|
||||
|
||||
assert compatibility_call(side_effect, Command(), Command())
|
||||
|
Reference in New Issue
Block a user