configcommands: Fix :config-list-remove with invalid value
This commit is contained in:
parent
9d80bc2076
commit
621f20adb3
|
|
@ -67,6 +67,8 @@ Fixed
|
||||||
(#8679).
|
(#8679).
|
||||||
- Added site-specific quirk for gitlab.gnome.org agressively blocking old
|
- Added site-specific quirk for gitlab.gnome.org agressively blocking old
|
||||||
Chromium versions (and thus QtWebEngine) (#8509).
|
Chromium versions (and thus QtWebEngine) (#8509).
|
||||||
|
- Using `:config-list-remove` with an invalid value for the respective option
|
||||||
|
type now corrently displays an error instead of crashing.
|
||||||
|
|
||||||
[[v3.5.1]]
|
[[v3.5.1]]
|
||||||
v3.5.1 (2025-06-05)
|
v3.5.1 (2025-06-05)
|
||||||
|
|
|
||||||
|
|
@ -356,9 +356,8 @@ class ConfigCommands:
|
||||||
raise cmdutils.CommandError(":config-list-remove can only be used "
|
raise cmdutils.CommandError(":config-list-remove can only be used "
|
||||||
"for lists")
|
"for lists")
|
||||||
|
|
||||||
converted = opt.typ.valtype.from_str(value)
|
|
||||||
|
|
||||||
with self._handle_config_error():
|
with self._handle_config_error():
|
||||||
|
converted = opt.typ.valtype.from_str(value)
|
||||||
option_value = self._config.get_mutable_obj(option)
|
option_value = self._config.get_mutable_obj(option)
|
||||||
|
|
||||||
if converted not in option_value:
|
if converted not in option_value:
|
||||||
|
|
|
||||||
|
|
@ -315,9 +315,10 @@ class TestAdd:
|
||||||
with pytest.raises(cmdutils.CommandError, match="Invalid value ''"):
|
with pytest.raises(cmdutils.CommandError, match="Invalid value ''"):
|
||||||
commands.config_list_add('content.blocking.whitelist', '')
|
commands.config_list_add('content.blocking.whitelist', '')
|
||||||
|
|
||||||
# FIXME test value conversion for :list-add like in test_dict_add_value_type
|
def test_list_add_value_type(self, commands, config_stub):
|
||||||
# (once we have a List config option using a non-str type, or a way to
|
commands.config_list_add("completion.web_history.exclude", "*")
|
||||||
# dynamically add new option definitions).
|
value = config_stub.val.completion.web_history.exclude
|
||||||
|
assert value == [urlmatch.UrlPattern("*")]
|
||||||
|
|
||||||
@pytest.mark.parametrize('value', ['test1', 'test2'])
|
@pytest.mark.parametrize('value', ['test1', 'test2'])
|
||||||
@pytest.mark.parametrize('temp', [True, False])
|
@pytest.mark.parametrize('temp', [True, False])
|
||||||
|
|
@ -410,9 +411,16 @@ class TestRemove:
|
||||||
match="#133742 is not in colors.completion.fg!"):
|
match="#133742 is not in colors.completion.fg!"):
|
||||||
commands.config_list_remove('colors.completion.fg', '#133742')
|
commands.config_list_remove('colors.completion.fg', '#133742')
|
||||||
|
|
||||||
# FIXME test value conversion for :list-remove like in test_dict_add_value_type
|
def test_list_remove_value_type(self, commands, config_stub):
|
||||||
# (once we have a List config option using a non-str type, or a way to
|
config_stub.val.completion.web_history.exclude = ["*"]
|
||||||
# dynamically add new option definitions).
|
commands.config_list_remove("completion.web_history.exclude", "*")
|
||||||
|
assert not config_stub.val.completion.web_history.exclude
|
||||||
|
|
||||||
|
def test_list_remove_invalid_value(self, commands, config_stub):
|
||||||
|
with pytest.raises(
|
||||||
|
cmdutils.CommandError,
|
||||||
|
match="Invalid value '::' - Pattern without host"):
|
||||||
|
commands.config_list_remove("completion.web_history.exclude", "::")
|
||||||
|
|
||||||
@pytest.mark.parametrize('key', ['w', 'q'])
|
@pytest.mark.parametrize('key', ['w', 'q'])
|
||||||
@pytest.mark.parametrize('temp', [True, False])
|
@pytest.mark.parametrize('temp', [True, False])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue