From 6e719d1796c0a2669f986e38a3bb9f9f74afb7c3 Mon Sep 17 00:00:00 2001 From: cryzed Date: Wed, 8 Nov 2017 15:08:36 +0100 Subject: [PATCH 1/2] Fix issue #3251 --- qutebrowser/config/config.py | 5 +++++ tests/unit/config/test_config.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index f3ea11f40..b519c5354 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -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)) diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index b609a4255..73bf76ecd 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -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: From 222c51aa6eb503901769048a817781adad649a31 Mon Sep 17 00:00:00 2001 From: cryzed Date: Wed, 8 Nov 2017 16:34:40 +0100 Subject: [PATCH 2/2] Ignore additional Qt error messages --- pytest.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytest.ini b/pytest.ini index 0cc5e49aa..5da383764 100644 --- a/pytest.ini +++ b/pytest.ini @@ -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