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 - 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"] 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)