Avoid calling configdata.init() in tests

It takes unnecessary time (20ms without C extensions) to initialize it over and
over again - and for some reason, it takes 20s (!) on Travis.
This commit is contained in:
Florian Bruhin 2017-07-04 07:28:07 +02:00
parent 56ec5719a2
commit 8933b4c5da
2 changed files with 9 additions and 3 deletions

View File

@ -200,10 +200,16 @@ def cmdline_test(request):
return request.param
@pytest.fixture(scope='session')
def configdata_init():
"""Initialize configdata if needed."""
if configdata.DATA is None:
configdata.init()
@pytest.fixture
def config_stub(stubs, monkeypatch):
def config_stub(stubs, monkeypatch, configdata_init):
"""Fixture which provides a fake config object."""
configdata.init()
yaml_config = stubs.FakeYamlConfig()
conf = config.Config(yaml_config=yaml_config)

View File

@ -31,8 +31,8 @@ from qutebrowser.utils import usertypes
def test_init(config_stub):
"""Test reading the default yaml file and validating the values."""
# configdata.init() is called by config_stub
config_stub.val.aliases = {}
configdata.init()
assert isinstance(configdata.DATA, dict)
assert 'ignore_case' in configdata.DATA
for option in configdata.DATA.values():