diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 07bd446be..3c3556749 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -84,7 +84,7 @@ def reset_locale(): @pytest.fixture def fakeredis_client(monkeypatch): worker_id = os.environ.get("PYTEST_XDIST_WORKER") - if worker_id.startswith("gw"): + if worker_id and worker_id.startswith("gw"): redis_port = 1000 + int(worker_id.replace("gw", "")) else: redis_port = 1000 @@ -119,3 +119,13 @@ def fakeredis_client(monkeypatch): redis.flushall() monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False) yield redis + + +@pytest.fixture(autouse=True) +def set_lock_namespaces(request): + worker_id = os.environ.get("PYTEST_XDIST_WORKER") + if worker_id and worker_id.startswith("gw"): + with override_settings(DATABASE_ADVISORY_LOCK_INDEX=int(worker_id.replace("gw", ""))): + yield + else: + yield