27 lines
924 B
Python
27 lines
924 B
Python
import os
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def django_db_setup(django_test_environment, django_db_blocker):
|
|
"""
|
|
Override pytest-django's default DB setup to:
|
|
- Use the local unix-socket superuser instead of the .env credentials
|
|
(skipped in CI, where the DB service credentials come from the
|
|
environment)
|
|
- Remove psycopg3 connection pooling (pool=True conflicts with test
|
|
transaction wrapping and causes PoolTimeout during test-DB creation)
|
|
"""
|
|
from django.conf import settings
|
|
from django.test.utils import setup_databases
|
|
|
|
db = settings.DATABASES["default"]
|
|
if not os.environ.get("CI"):
|
|
db["USER"] = "hashdal"
|
|
db["PASSWORD"] = ""
|
|
db["HOST"] = ""
|
|
db["OPTIONS"] = {} # clear pool=True; psycopg3 pool conflicts with pytest-django
|
|
|
|
with django_db_blocker.unblock():
|
|
setup_databases(verbosity=0, interactive=False)
|