Skip to content

Commit

Permalink
Lock/unlock of db breaks if pytest is executed twice in the same process
Browse files Browse the repository at this point in the history
  • Loading branch information
boxed committed Sep 26, 2024
1 parent 1157a7c commit f2b7a93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,9 @@ def _dj_db_wrapper(self) -> django.db.backends.base.base.BaseDatabaseWrapper:

# The first time the _dj_db_wrapper is accessed, we will save a
# reference to the real implementation.
if self._real_ensure_connection is None:
self._real_ensure_connection = BaseDatabaseWrapper.ensure_connection
if not hasattr(BaseDatabaseWrapper, "_real_ensure_connection"):
BaseDatabaseWrapper._real_ensure_connection = BaseDatabaseWrapper.ensure_connection
self._real_ensure_connection = BaseDatabaseWrapper._real_ensure_connection

return BaseDatabaseWrapper

Expand Down

0 comments on commit f2b7a93

Please sign in to comment.