diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index 7b1a26e71..e19e15695 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -179,14 +179,13 @@ class YamlConfig(QObject): elif name in configdata.MIGRATIONS.deleted: log.config.debug("Removing {}".format(name)) del self._values[name] - persist = 'tabs.persist_mode_on_change' if persist in self._values: if self._values[persist]: self._values['tabs.mode_on_change'] = 'persist' else: self._values['tabs.mode_on_change'] = 'normal' - del self._values[persist] + self.unset(persist) def _validate(self): """Make sure all settings exist.""" diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 8659cf891..116d305d3 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -169,6 +169,30 @@ class TestYaml: assert ' old:' not in lines assert ' new:' not in lines + def test_merge_persist_false(self, monkeypatch, yaml, config_tmpdir): + """Migration of tabs.persist_mode_on_change: False.""" + autoconfig = config_tmpdir / 'autoconfig.yml' + autoconfig.write_text('global:\n tabs.persist_mode_on_change: False', encoding='utf-8') + + yaml.load() + yaml._save() + + lines = autoconfig.read_text('utf-8').splitlines() + assert ' tabs.persist_mode_on_change:' not in lines + assert ' tabs.mode_on_change: normal' in lines + + def test_merge_persist_true(self, monkeypatch, yaml, config_tmpdir): + """Migration of tabs.persist_mode_on_change: True.""" + autoconfig = config_tmpdir / 'autoconfig.yml' + autoconfig.write_text('global:\n tabs.persist_mode_on_change: True', encoding='utf-8') + + yaml.load() + yaml._save() + + lines = autoconfig.read_text('utf-8').splitlines() + assert ' tabs.persist_mode_on_change:' not in lines + assert ' tabs.mode_on_change: persist' in lines + def test_renamed_key_unknown_target(self, monkeypatch, yaml, config_tmpdir): """A key marked as renamed with invalid name should raise an error."""