From 75181e16faca3c590308e3c8843d714064004448 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 19 Feb 2018 19:16:50 +0100 Subject: [PATCH] Fix test_models.py The Config object got initialized via the config_stub fixture early, so we need to force it to re-init its values after patching configdata.DATA. --- qutebrowser/config/config.py | 3 +++ tests/unit/completion/test_models.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 8f34b6e44..4ad00fec4 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -253,7 +253,10 @@ class Config(QObject): self.changed.connect(_render_stylesheet.cache_clear) self._mutables = {} self._yaml = yaml_config + self._init_values() + def _init_values(self): + """Populate the self._values dict.""" self._values = {} for name, opt in configdata.DATA.items(): self._values[name] = configutils.Values(opt) diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index ff9a24112..32e6920fe 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -80,9 +80,9 @@ def cmdutils_stub(monkeypatch, stubs): @pytest.fixture() -def configdata_stub(monkeypatch, configdata_init): +def configdata_stub(config_stub, monkeypatch, configdata_init): """Patch the configdata module to provide fake data.""" - return monkeypatch.setattr(configdata, 'DATA', collections.OrderedDict([ + monkeypatch.setattr(configdata, 'DATA', collections.OrderedDict([ ('aliases', configdata.Option( name='aliases', description='Aliases for commands.', @@ -132,6 +132,7 @@ def configdata_stub(monkeypatch, configdata_init): backends=[], raw_backends=None)), ])) + config_stub._init_values() @pytest.fixture