Fix tests for configcache
This commit is contained in:
parent
cc09f6c962
commit
d4cf5045ab
@ -42,9 +42,6 @@ class ConfigCache():
|
||||
if attr in self.cache:
|
||||
self.cache[attr] = config.instance.get(attr)
|
||||
|
||||
def __setitem__(self, attr, _value):
|
||||
raise Exception("ConfigCache cannot be used to set values.")
|
||||
|
||||
def __getitem__(self, attr: str):
|
||||
if attr not in self.cache:
|
||||
assert not config.instance.get_opt(attr).supports_pattern
|
||||
|
@ -147,6 +147,8 @@ PERFECT_FILES = [
|
||||
'config/configcommands.py'),
|
||||
('tests/unit/config/test_configutils.py',
|
||||
'config/configutils.py'),
|
||||
('tests/unit/config/test_configcache.py',
|
||||
'config/configcache.py'),
|
||||
|
||||
('tests/unit/utils/test_qtutils.py',
|
||||
'utils/qtutils.py'),
|
||||
|
@ -42,7 +42,7 @@ from PyQt5.QtNetwork import QNetworkCookieJar
|
||||
import helpers.stubs as stubsmod
|
||||
import helpers.utils
|
||||
from qutebrowser.config import (config, configdata, configtypes, configexc,
|
||||
configfiles)
|
||||
configfiles, configcache)
|
||||
from qutebrowser.utils import objreg, standarddir, utils, usertypes
|
||||
from qutebrowser.browser import greasemonkey
|
||||
from qutebrowser.browser.webkit import cookies
|
||||
@ -253,6 +253,9 @@ def config_stub(stubs, monkeypatch, configdata_init, yaml_config_stub):
|
||||
container = config.ConfigContainer(conf)
|
||||
monkeypatch.setattr(config, 'val', container)
|
||||
|
||||
cache = configcache.ConfigCache()
|
||||
monkeypatch.setattr(config, 'configcache', cache)
|
||||
|
||||
try:
|
||||
configtypes.Font.monospace_fonts = container.fonts.monospace
|
||||
except configexc.NoOptionError:
|
||||
|
@ -21,15 +21,28 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from qutebrowser.config import configcache, config
|
||||
from qutebrowser.config import config
|
||||
|
||||
|
||||
class TestConfigCache:
|
||||
|
||||
@pytest.fixture
|
||||
def ccache(self, config_stub):
|
||||
return configcache.ConfigCache()
|
||||
return config.configcache
|
||||
|
||||
def test_configcache_except_pattern(self, ccache):
|
||||
with pytest.raises(AssertionError):
|
||||
ccache['content.javascript.enabled']
|
||||
assert ccache['content.javascript.enabled']
|
||||
|
||||
def test_configcache_error_set(self, ccache):
|
||||
with pytest.raises(TypeError):
|
||||
ccache['content.javascript.enabled'] = True
|
||||
|
||||
def test_configcache_get(self, ccache):
|
||||
assert not ccache['auto_save.session']
|
||||
assert not ccache['auto_save.session']
|
||||
|
||||
def test_configcache_get_after_set(self, ccache):
|
||||
assert not ccache['auto_save.session']
|
||||
config.val.auto_save.session = True
|
||||
assert ccache['auto_save.session']
|
||||
|
Loading…
Reference in New Issue
Block a user