Merge remote-tracking branch 'origin/pr/3259'

This commit is contained in:
Florian Bruhin 2017-11-10 09:42:05 +01:00
commit 8df759ecad
3 changed files with 13 additions and 0 deletions

View File

@ -56,4 +56,6 @@ qt_log_ignore =
^QQuickWidget::invalidateRenderControl could not make context current
^libpng warning: iCCP: known incorrect sRGB profile
^inotify_add_watch(".*") failed: "No space left on device"
^QSettings::value: Empty key passed
^Icon theme ".*" not found
xfail_strict = true

View File

@ -170,6 +170,11 @@ class KeyConfig:
def bind(self, key, command, *, mode, save_yaml=False):
"""Add a new binding from key to command."""
if command is not None and not command.strip():
raise configexc.KeybindingError(
"Can't add binding '{}' with empty command in {} "
'mode'.format(key, mode))
key = self._prepare(key, mode)
log.keyboard.vdebug("Adding binding {} -> {} in mode {}.".format(
key, command, mode))

View File

@ -285,6 +285,12 @@ class TestKeyConfig:
key_config_stub.unbind('a')
assert key_config_stub.get_command('a', mode='normal') is None
def test_empty_command(self, key_config_stub):
"""Try binding a key to an empty command."""
message = "Can't add binding 'x' with empty command in normal mode"
with pytest.raises(configexc.KeybindingError, match=message):
key_config_stub.bind('x', ' ', mode='normal')
class TestConfig: