Function-scoped fixture with table truncation cleanup. After each test, all tables are truncated (DELETE FROM). Faster than db_isolated but slower than db (transaction rollback). Use when testing transaction behavior (can't use rollback for cleanup). Usage: @pytest.ma
(db_module)
| 157 | |
| 158 | @pytest_asyncio.fixture(scope="function") |
| 159 | async def db_truncate(db_module): |
| 160 | """ |
| 161 | Function-scoped fixture with table truncation cleanup. |
| 162 | |
| 163 | After each test, all tables are truncated (DELETE FROM). |
| 164 | Faster than db_isolated but slower than db (transaction rollback). |
| 165 | |
| 166 | Use when testing transaction behavior (can't use rollback for cleanup). |
| 167 | |
| 168 | Usage: |
| 169 | @pytest.mark.asyncio |
| 170 | async def test_with_transactions(db_truncate): |
| 171 | async with in_transaction(): |
| 172 | await Model.create(name="test") |
| 173 | # Table truncated after test |
| 174 | """ |
| 175 | yield db_module |
| 176 | await _truncate_all_tables(db_module) |
| 177 | |
| 178 | |
| 179 | # ============================================================================ |
nothing calls this directly
no test coverage detected
searching dependent graphs…