summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/config/config.py5
-rw-r--r--tests/unit/config/test_config.py13
2 files changed, 16 insertions, 2 deletions
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
index 834709ae6..de210d50d 100644
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -549,11 +549,12 @@ class Config(QObject):
Here, we check all those saved copies for mutations, and if something
mutated, we call set_obj again so we save the new value.
"""
- for name, (old_value, new_value) in self._mutables.items():
+ mutables = self._mutables.items()
+ self._mutables = {}
+ for name, (old_value, new_value) in mutables:
if old_value != new_value:
log.config.debug("{} was mutated, updating".format(name))
self.set_obj(name, new_value, save_yaml=save_yaml)
- self._mutables = {}
def dump_userconfig(self) -> str:
"""Get the part of the config which was changed by the user.
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
index b88bc2f8d..73941e9cb 100644
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -613,6 +613,19 @@ class TestConfig:
expected = {'X-Foo': 'fooval', 'X-Bar': 'barval'}
assert conf.get_obj(option) == expected
+ def test_get_mutable_invalid_value(self, conf):
+ """Make sure invalid values aren't stored in mutables."""
+ option = 'keyhint.blacklist'
+ obj = conf.get_mutable_obj(option)
+ assert obj == []
+ obj.append(42)
+
+ with pytest.raises(configexc.ValidationError):
+ conf.update_mutables()
+
+ obj = conf.get_mutable_obj(option)
+ assert obj == []
+
def test_get_obj_unknown_mutable(self, conf):
"""Make sure we don't have unknown mutable types."""
with pytest.raises(AssertionError):