diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index e19e15695..2220de93d 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -175,10 +175,10 @@ class YamlConfig(QObject): new_name = configdata.MIGRATIONS.renamed[name] log.config.debug("Renaming {} to {}".format(name, new_name)) self._values[new_name] = self._values[name] - del self._values[name] + self.unset(name) elif name in configdata.MIGRATIONS.deleted: log.config.debug("Removing {}".format(name)) - del self._values[name] + self.unset(name) persist = 'tabs.persist_mode_on_change' if persist in self._values: if self._values[persist]: diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 101b883cd..341fad689 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -152,7 +152,7 @@ class TestYaml: yaml._save() lines = autoconfig.read_text('utf-8').splitlines() - assert ' hello:' not in lines + assert ' hello: world' not in lines def test_renamed_key(self, monkeypatch, yaml, config_tmpdir): """A key marked as renamed should be renamed properly.""" @@ -166,34 +166,22 @@ class TestYaml: yaml._save() lines = autoconfig.read_text('utf-8').splitlines() - assert ' old:' not in lines - assert ' new:' not in lines + assert ' old: value' not in lines + assert ' tabs.show: value' in lines - def test_merge_persist_false(self, monkeypatch, yaml, config_tmpdir): - """Migration of tabs.persist_mode_on_change: False.""" + @pytest.mark.parametrize('persist', [True, False]) + def test_merge_persist(self, yaml, config_tmpdir, persist): + """Tests for migration of tabs.persist_mode_on_change.""" autoconfig = config_tmpdir / 'autoconfig.yml' - autoconfig.write_text('global:\n tabs.persist_mode_on_change: False', - encoding='utf-8') - + autoconfig.write_text('global:\n tabs.persist_mode_on_change: {}'. + format(persist), encoding='utf-8') yaml.load() yaml._save() lines = autoconfig.read_text('utf-8').splitlines() + mode = 'persist' if persist else 'normal' 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 + assert ' tabs.mode_on_change: {}'.format(mode) in lines def test_renamed_key_unknown_target(self, monkeypatch, yaml, config_tmpdir):