Skip to content

Commit 9347fb8

Browse files
abondarclaude
andcommitted
Fix _reset_conn_state to handle None db_config
When finalizer() sets connections._db_config = None and another test runs on the same worker (with pytest-xdist), _reset_conn_state() would fail because it tried to call .clear() on None. This fix checks if _db_config is not None before clearing it. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6dcc871 commit 9347fb8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tortoise/contrib/test/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ async def asyncSetUp(self) -> None:
271271
def _reset_conn_state(self) -> None:
272272
# clearing the storage and db config
273273
connections._clear_storage()
274-
connections.db_config.clear()
274+
if connections._db_config is not None:
275+
connections._db_config.clear()
275276

276277
async def asyncTearDown(self) -> None:
277278
await self._tearDownDB()

0 commit comments

Comments
 (0)