Prepare test harness for Orca 50 rebase
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
os.environ["GSETTINGS_BACKEND"] = "memory"
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC_ROOT = REPO_ROOT / "src"
|
||||
@@ -63,3 +67,27 @@ for generated_module in ("cthulhu_i18n", "cthulhu_platform"):
|
||||
loaded_module = _load_generated_module(generated_module)
|
||||
sys.modules[f"cthulhu.{generated_module}"] = loaded_module
|
||||
setattr(cthulhu, generated_module, loaded_module)
|
||||
|
||||
|
||||
from cthulhu_test_fixtures import test_context # noqa: E402,F401
|
||||
|
||||
|
||||
def clean_all_cthulhu_modules() -> None:
|
||||
modules_to_remove = [
|
||||
module_name
|
||||
for module_name in sys.modules
|
||||
if module_name.startswith("cthulhu.")
|
||||
and module_name not in {"cthulhu.cthulhu_i18n", "cthulhu.cthulhu_platform"}
|
||||
]
|
||||
for module_name in modules_to_remove:
|
||||
sys.modules.pop(module_name, None)
|
||||
|
||||
|
||||
def pytest_configure(config: pytest.Config) -> None:
|
||||
config.addinivalue_line("markers", "unit: marks tests as unit tests")
|
||||
|
||||
|
||||
def pytest_runtest_setup(item: pytest.Item) -> None:
|
||||
clean_all_cthulhu_modules()
|
||||
if str(SRC_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(SRC_ROOT))
|
||||
|
||||
Reference in New Issue
Block a user