Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions message_ix/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
# Pytest hooks


def pytest_configure(config: pytest.Config) -> None:
"""Force iam-units to use a distinct cache for each worker.

Work around for https://github.com/hgrecco/flexcache/issues/6 /
https://github.com/IAMconsortium/units/issues/54.
"""
name = f"iam-units-{os.environ.get('PYTEST_XDIST_WORKER', '')}".rstrip("-")
os.environ["IAM_UNITS_CACHE"] = str(config.cache.mkdir(name))


def pytest_report_header(config: pytest.Config, start_path: Path) -> str:
"""Add the message_ix import path to the pytest report header."""
import message_ix
Expand Down
Loading