Add the option name to the backend error message
This commit is contained in:
parent
28d7c5e204
commit
0afd6b23c9
@ -257,7 +257,7 @@ class Config(QObject):
|
||||
"""Set the given option to the given value."""
|
||||
if not isinstance(objects.backend, objects.NoBackend):
|
||||
if objects.backend not in opt.backends:
|
||||
raise configexc.BackendError(objects.backend)
|
||||
raise configexc.BackendError(opt.name, objects.backend)
|
||||
|
||||
opt.typ.to_py(value) # for validation
|
||||
self._values[opt.name] = opt.typ.from_obj(value)
|
||||
|
@ -35,9 +35,9 @@ class BackendError(Error):
|
||||
|
||||
"""Raised when this setting is unavailable with the current backend."""
|
||||
|
||||
def __init__(self, backend):
|
||||
super().__init__("This setting is not available with the {} "
|
||||
"backend!".format(backend.name))
|
||||
def __init__(self, name, backend):
|
||||
super().__init__("The {} setting is not available with the {} "
|
||||
"backend!".format(name, backend.name))
|
||||
|
||||
|
||||
class ValidationError(Error):
|
||||
|
@ -130,8 +130,8 @@ class TestSet:
|
||||
def test_set_wrong_backend(self, commands, monkeypatch):
|
||||
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebEngine)
|
||||
with pytest.raises(cmdexc.CommandError,
|
||||
match="This setting is not available with the "
|
||||
"QtWebEngine backend!"):
|
||||
match="The content.cookies.accept setting is not "
|
||||
"available with the QtWebEngine backend!"):
|
||||
commands.set(0, 'content.cookies.accept', 'all')
|
||||
|
||||
@pytest.mark.parametrize('option', ['?', 'url.auto_search'])
|
||||
|
@ -49,8 +49,9 @@ def test_no_option_error_clash():
|
||||
|
||||
|
||||
def test_backend_error():
|
||||
e = configexc.BackendError(usertypes.Backend.QtWebKit)
|
||||
assert str(e) == "This setting is not available with the QtWebKit backend!"
|
||||
e = configexc.BackendError('foo', usertypes.Backend.QtWebKit)
|
||||
expected = "The foo setting is not available with the QtWebKit backend!"
|
||||
assert str(e) == expected
|
||||
|
||||
|
||||
def test_desc_with_text():
|
||||
|
Loading…
Reference in New Issue
Block a user