mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Integrate automatic redis startup with the project
This commit is contained in:
4
sith/environ.py
Normal file
4
sith/environ.py
Normal file
@ -0,0 +1,4 @@
|
||||
from environs import Env
|
||||
|
||||
env = Env()
|
||||
_ = env.read_env()
|
23
sith/pytest.py
Normal file
23
sith/pytest.py
Normal file
@ -0,0 +1,23 @@
|
||||
import pytest
|
||||
|
||||
from processes.composer import start_composer, stop_composer
|
||||
|
||||
from .environ import env
|
||||
|
||||
# pytest-django uses the load_initial_conftest hook
|
||||
# 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"""
|
||||
if (procfile := env.str("PROCFILE_PYTEST", None)) is not None:
|
||||
start_composer(procfile)
|
||||
|
||||
|
||||
def pytest_unconfigure(config):
|
||||
stop_composer()
|
@ -42,14 +42,11 @@ from pathlib import Path
|
||||
import sentry_sdk
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from environs import Env
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
|
||||
from .environ import env
|
||||
from .honeypot import custom_honeypot_error
|
||||
|
||||
env = Env()
|
||||
env.read_env()
|
||||
|
||||
BASE_DIR = Path(__file__).parent.parent.resolve()
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
|
Reference in New Issue
Block a user