v0.166.0
 1"""
 2Declarative test decorators for database behavior.
 3"""
 4
 5from collections.abc import Callable
 6
 7from plain.testing import tag
 8
 9__all__ = ["isolated_db"]
10
11ISOLATED_DB_TAG = "postgres:isolated_db"
12
13
14def isolated_db(func: Callable) -> Callable:
15    """
16    Run this test against its own separately-created database instead of a
17    rolled-back transaction on the shared test database.
18
19    For tests that exercise DDL or transaction behavior itself (migrations,
20    convergence, commit semantics) — anything that can't run inside a
21    transaction that never commits.
22
23        @isolated_db
24        def test_convergence_adds_index():
25            ...
26    """
27    return tag(ISOLATED_DB_TAG)(func)