Show better error message when trying to toggle with :set

This commit is contained in:
Florian Bruhin 2017-10-17 06:26:42 +02:00
parent 544c508fac
commit d8384ced0a
3 changed files with 21 additions and 2 deletions

View File

@ -42,6 +42,11 @@ Fixed
- Handle a filesystem going read-only gracefully
- Fix wrong rendering of keys like `<back>` in the completion
Changed
~~~~~~~
- Nicer error messages and other minor improvements
v1.0.1
------

View File

@ -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

View File

@ -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?'.