19 lines
642 B
Python
19 lines
642 B
Python
"""Isolate import-time ASGI construction before pytest collects test modules."""
|
|
import os
|
|
from tempfile import TemporaryDirectory
|
|
|
|
|
|
_import_home = TemporaryDirectory(prefix="assistant-server-test-import-")
|
|
_previous = {key: os.environ.get(key) for key in ("ASSISTANT_LEARNING_HOME", "ASSISTANT_DATABASE_URL")}
|
|
os.environ["ASSISTANT_LEARNING_HOME"] = _import_home.name
|
|
os.environ["ASSISTANT_DATABASE_URL"] = ""
|
|
|
|
|
|
def pytest_sessionfinish(session, exitstatus):
|
|
for key, value in _previous.items():
|
|
if value is None:
|
|
os.environ.pop(key, None)
|
|
else:
|
|
os.environ[key] = value
|
|
_import_home.cleanup()
|