Skip to content

Commit 062ab4e

Browse files
committed
Lock/unlock of db breaks if pytest is executed twice in the same process (fixes #1147)
1 parent 1157a7c commit 062ab4e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pytest_django/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ def get_order_number(test: pytest.Item) -> int:
476476
items.sort(key=get_order_number)
477477

478478

479+
def pytest_unconfigure(config: pytest.Config) -> None:
480+
if blocking_manager_key not in config.stash:
481+
return
482+
blocking_manager = config.stash[blocking_manager_key]
483+
blocking_manager.unblock()
484+
485+
479486
@pytest.fixture(autouse=True, scope="session")
480487
def django_test_environment(request: pytest.FixtureRequest) -> Generator[None, None, None]:
481488
"""Setup Django's test environment for the testing session.

0 commit comments

Comments
 (0)