2025-02-26 10:42:11 +01:00
|
|
|
import atexit
|
|
|
|
|
2025-02-17 15:58:53 +01:00
|
|
|
import pytest
|
|
|
|
|
2025-02-20 18:38:15 +01:00
|
|
|
from .composer import start_composer, stop_composer
|
2025-03-04 14:48:44 +01:00
|
|
|
from .settings import PROCFILE_SERVICE
|
2025-02-17 15:58:53 +01:00
|
|
|
|
|
|
|
# it's the first hook loaded by pytest and can only
|
|
|
|
# be defined in a proper pytest plugin
|
|
|
|
# To use the composer before pytest-django loads
|
|
|
|
# we need to define this hook and thus create a proper
|
|
|
|
# pytest plugin. We can't just use conftest.py
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.hookimpl(tryfirst=True)
|
|
|
|
def pytest_load_initial_conftests(early_config, parser, args):
|
|
|
|
"""Hook that loads the composer before the pytest-django plugin"""
|
2025-03-04 14:48:44 +01:00
|
|
|
if PROCFILE_SERVICE is not None:
|
|
|
|
start_composer(PROCFILE_SERVICE)
|
|
|
|
_ = atexit.register(stop_composer, procfile=PROCFILE_SERVICE)
|