Skip to content
Open
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
17 changes: 14 additions & 3 deletions source/bind/python/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import os
import sys
from pathlib import Path

import pytest

PROJECT_PYTHON_DIR = Path(__file__).resolve().parents[1]

# In CI, this fixture is exercising a build CI just produced, so an import or
# init failure is a real failure, not an optional/environment-dependent skip.
_IN_CI = bool(os.environ.get("CI") or os.environ.get("GITHUB_ACTIONS"))


def _skip_or_fail(message):
if _IN_CI:
pytest.fail(message)
pytest.skip(message)


@pytest.fixture(scope="session")
def cea_module():
try:
import cea
except Exception as exc:
pytest.skip(f"cea import failed: {exc}")
_skip_or_fail(f"cea import failed: {exc}")
try:
if hasattr(cea, "is_initialized") and not cea.is_initialized():
pytest.skip("cea database not initialized")
_skip_or_fail("cea database not initialized")
except Exception as exc:
pytest.skip(f"cea initialization check failed: {exc}")
_skip_or_fail(f"cea initialization check failed: {exc}")
return cea
Loading