Skip to content

Commit 259fb85

Browse files
authored
Lock/unlock of db breaks if pytest is executed twice in the same process (#1148)
Fixes #1147
1 parent 23adcbe commit 259fb85

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pytest_django/plugin.py

+7
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)