Import TLJH only when needed in conftest.py

This commit is contained in:
yuvipanda
2018-10-31 10:25:29 -07:00
parent 5374f5eaf5
commit b644599af8

View File

@@ -4,12 +4,14 @@ import os
from pytest import fixture
from tljh.config import CONFIG_FILE, reload_component
@fixture
def preserve_config(request):
"""Fixture to save and restore config around tests"""
# Import TLJH only when needed. This lets us run tests in places
# where TLJH is not installed - particularly, the 'distro check' test.
from tljh.config import CONFIG_FILE, reload_component
if os.path.exists(CONFIG_FILE):
with open(CONFIG_FILE) as f:
save_config = f.read()