diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index f8f9e7902..eb2a81594 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -136,8 +136,8 @@ class KeyConfig: def __init__(self, config): self._config = config - def _prepare(self, key, mode): - """Make sure the given mode exists.""" + def _validate(self, key, mode): + """Validate the given key and mode.""" # Catch old usage of this code assert isinstance(key, keyutils.KeySequence), key if mode not in configdata.DATA['bindings.default'].default: @@ -170,7 +170,7 @@ class KeyConfig: def get_command(self, key, mode, default=False): """Get the command for a given key (or None).""" - self._prepare(key, mode) + self._validate(key, mode) if default: bindings = dict(val.bindings.default[mode]) else: @@ -184,7 +184,7 @@ class KeyConfig: "Can't add binding '{}' with empty command in {} " 'mode'.format(key, mode)) - self._prepare(key, mode) + self._validate(key, mode) log.keyboard.vdebug("Adding binding {} -> {} in mode {}.".format( key, command, mode)) @@ -196,7 +196,7 @@ class KeyConfig: def bind_default(self, key, *, mode='normal', save_yaml=False): """Restore a default keybinding.""" - self._prepare(key, mode) + self._validate(key, mode) bindings_commands = self._config.get_mutable_obj('bindings.commands') try: @@ -208,7 +208,7 @@ class KeyConfig: def unbind(self, key, *, mode='normal', save_yaml=False): """Unbind the given key in the given mode.""" - self._prepare(key, mode) + self._validate(key, mode) bindings_commands = self._config.get_mutable_obj('bindings.commands') diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index f47ee7a0a..40e82ba4b 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -103,15 +103,13 @@ class TestKeyConfig: """Get a dict with no bindings.""" return {'normal': {}} - def test_prepare_invalid_mode(self, key_config_stub): - """Make sure prepare checks the mode.""" + def test_validate_invalid_mode(self, key_config_stub): with pytest.raises(configexc.KeybindingError): - assert key_config_stub._prepare(keyseq('x'), 'abnormal') + assert key_config_stub._validate(keyseq('x'), 'abnormal') - def test_prepare_invalid_type(self, key_config_stub): - """Make sure prepare checks the type.""" + def test_validate_invalid_type(self, key_config_stub): with pytest.raises(AssertionError): - assert key_config_stub._prepare('x', 'normal') + assert key_config_stub._validate('x', 'normal') @pytest.mark.parametrize('commands, expected', [ # Unbinding default key