MCPcopy
hub / github.com/tortoise/tortoise-orm / db_postgres

Function db_postgres

tests/contrib/postgres/conftest.py:43–60  ·  view source on GitHub ↗

Function-scoped fixture with transaction rollback for postgres tests. Equivalent to: test.TestCase with standard testmodels.

(db_module_postgres)

Source from the content-addressed store, hash-verified

41
42@pytest_asyncio.fixture(scope="function")
43async def db_postgres(db_module_postgres):
44 """
45 Function-scoped fixture with transaction rollback for postgres tests.
46
47 Equivalent to: test.TestCase with standard testmodels.
48 """
49 conn = db_module_postgres.db()
50 transaction = conn._in_transaction()
51 await transaction.__aenter__()
52
53 try:
54 yield db_module_postgres
55 finally:
56
57 class _RollbackException(Exception):
58 pass
59
60 await transaction.__aexit__(_RollbackException, _RollbackException(), None)
61
62
63@pytest_asyncio.fixture(scope="function")

Callers

nothing calls this directly

Calls 5

_RollbackExceptionClass · 0.70
dbMethod · 0.45
_in_transactionMethod · 0.45
__aenter__Method · 0.45
__aexit__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…