From d8384ced0a958e9841dfbb7f7b0d75f1f8c92f19 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 17 Oct 2017 06:26:42 +0200 Subject: [PATCH] Show better error message when trying to toggle with :set --- doc/changelog.asciidoc | 5 +++++ qutebrowser/config/configcommands.py | 4 ++++ tests/unit/config/test_configcommands.py | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 3e2aeeb12..f0af67b97 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -42,6 +42,11 @@ Fixed - Handle a filesystem going read-only gracefully - Fix wrong rendering of keys like `` in the completion +Changed +~~~~~~~ + +- Nicer error messages and other minor improvements + v1.0.1 ------ diff --git a/qutebrowser/config/configcommands.py b/qutebrowser/config/configcommands.py index 5848c9680..340175f23 100644 --- a/qutebrowser/config/configcommands.py +++ b/qutebrowser/config/configcommands.py @@ -75,6 +75,10 @@ class ConfigCommands: tabbed_browser.openurl(QUrl('qute://settings'), newtab=False) return + if option.endswith('!'): + raise cmdexc.CommandError("Toggling values was moved to the " + ":config-cycle command") + if option.endswith('?') and option != '?': self._print_value(option[:-1]) return diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py index 1841e6260..c33bb54d4 100644 --- a/tests/unit/config/test_configcommands.py +++ b/tests/unit/config/test_configcommands.py @@ -133,9 +133,9 @@ class TestSet: "QtWebEngine backend!"): commands.set(0, 'content.cookies.accept', 'all') - @pytest.mark.parametrize('option', ['?', '!', 'url.auto_search']) + @pytest.mark.parametrize('option', ['?', 'url.auto_search']) def test_empty(self, commands, option): - """Run ':set ?' / ':set !' / ':set url.auto_search'. + """Run ':set ?' / ':set url.auto_search'. Should show an error. See https://github.com/qutebrowser/qutebrowser/issues/1109 @@ -145,6 +145,16 @@ class TestSet: "value"): commands.set(win_id=0, option=option) + def test_toggle(self, commands): + """Try toggling a value. + + Should show an nicer error. + """ + with pytest.raises(cmdexc.CommandError, + match="Toggling values was moved to the " + ":config-cycle command"): + commands.set(win_id=0, option='javascript.enabled!') + def test_invalid(self, commands): """Run ':set foo?'.