Skip to content

Commit f0917a6

Browse files
snopokeclaude
andcommitted
test(procrastinate): scope app fixture per-test
session-scope broke when run_worker's open_async() tore down the sync sub-connector PsycopgConnector creates lazily for sync defer(). The outer `with app.open():` didn't reopen it for the next test, so test 2's defer hit AppNotOpen. Function-scoped + idempotent apply_schema is the simplest reliable shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5fedc8d commit f0917a6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

integration_tests/test_procrastinate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ def _check_log_errors(caplog):
3636
pytest.fail(f"log errors during '{when}': {errors}")
3737

3838

39-
@pytest.fixture(scope="session")
39+
@pytest.fixture
4040
def app():
4141
# Async connector even though the tests are sync: run_worker raises
4242
# SyncConnectorConfigurationError on SyncPsycopgConnector. Async works in both contexts.
43+
#
44+
# Function-scoped because run_worker tears down the sync sub-connector
45+
# PsycopgConnector creates inside `app.open()`, and nothing reopens it for
46+
# the next test's defer() call. Cheap: apply_schema is idempotent.
4347
conn = procrastinate.PsycopgConnector(conninfo=PROCRASTINATE_DSN)
4448
app = procrastinate.App(connector=conn)
4549
with app.open():
46-
# Apply schema (idempotent — Procrastinate's apply_schema is safe to re-run).
4750
app.schema_manager.apply_schema()
4851
yield app
4952

0 commit comments

Comments
 (0)