/usr/local/lib/python3.11/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset. The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session" warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET)) F.E [100%] ==================================== ERRORS ==================================== _ ERROR at teardown of TestGetCampaignEntities.test_missing_ids_resolved_honestly _ -- params: Params | None = None, *, prepare: bool | None = None, binary: bool | None = None, ) -> Self: """ Execute a query or command to the database. """ try: with self._conn.lock: self._conn.wait( self._execute_gen(query, params, prepare=prepare, binary=binary) ) except e._NO_TRACEBACK as ex: > raise ex.with_traceback(None) E psycopg.errors.ObjectInUse: database "bulkmailer_test_32ead8eb" is being accessed by other users E DETAIL: There is 1 other session using the database. -- params: Params | None = None, *, prepare: bool | None = None, binary: bool | None = None, ) -> Self: """ Execute a query or command to the database. """ try: with self._conn.lock: self._conn.wait( self._execute_gen(query, params, prepare=prepare, binary=binary) ) except e._NO_TRACEBACK as ex: > raise ex.with_traceback(None) E sqlalchemy.exc.OperationalError: (psycopg.errors.ObjectInUse) database "bulkmailer_test_32ead8eb" is being accessed by other users E DETAIL: There is 1 other session using the database. E [SQL: DROP DATABASE IF EXISTS "bulkmailer_test_32ead8eb"] E (Background on this error at: https://sqlalche.me/e/20/e3q8) -- def test_invoice_numbers_unique_across_materialize_calls(self, db_engine): """Same campaign materialized twice (draft re-preview) — the collision set is per call, but DB uniqueness per campaign holds because rows are regenerated. Verified: two calls with the same recipient set produce distinct plans and both unique sets.""" from sqlalchemy.orm import Session with Session(db_engine, expire_on_commit=False) as db: f = _seed_fixture(db, n_recipients=8) recs = db.query(Recipient).filter_by(list_id=f["campaign"].recipient_list_id).all() res1 = _async_materialize(db_engine, f["campaign"], recs, preview=True) res2 = _async_materialize(db_engine, f["campaign"], recs, preview=True) invs1 = {r.generated_invoice_number for r in res1["rows"]} invs2 = {r.generated_invoice_number for r in res2["rows"]}