Skip to content

Commit 7f0e5d5

Browse files
committed
Fix env-var name for parallel tox tests
When running tests in parallel, we need to add a suffix to Django DB names to avoid clashes. This previously used `TOX_PARALLEL_ENV`, but Tox no longer sets this environment variable. Tox does set an environment variable called `TOX_ENV_NAME`, which works for this purpose, so use that instead.
1 parent 11f613d commit 7f0e5d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pytest_django/fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
def django_db_modify_db_settings_tox_suffix() -> None:
6767
skip_if_no_django()
6868

69-
tox_environment = os.getenv("TOX_PARALLEL_ENV")
69+
tox_environment = os.getenv("TOX_ENV_NAME")
7070
if tox_environment:
7171
# Put a suffix like _py27-django21 on tox workers
7272
_set_suffix_to_test_databases(suffix=tox_environment)

tests/test_db_setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def test_db_with_tox_suffix(
367367
monkeypatch: pytest.MonkeyPatch,
368368
) -> None:
369369
"A test to check that Tox DB suffix works when running in parallel."
370-
monkeypatch.setenv("TOX_PARALLEL_ENV", "py37-django22")
370+
monkeypatch.setenv("TOX_ENV_NAME", "py37-django22")
371371

372372
django_pytester.create_test_module(
373373
"""
@@ -395,7 +395,7 @@ def test_db_with_empty_tox_suffix(
395395
monkeypatch: pytest.MonkeyPatch,
396396
) -> None:
397397
"A test to check that Tox DB suffix is not used when suffix would be empty."
398-
monkeypatch.setenv("TOX_PARALLEL_ENV", "")
398+
monkeypatch.setenv("TOX_ENV_NAME", "")
399399

400400
django_pytester.create_test_module(
401401
"""
@@ -434,7 +434,7 @@ def test_db_with_tox_suffix(
434434
) -> None:
435435
"A test to check that both Tox and xdist suffixes work together."
436436
pytest.importorskip("xdist")
437-
monkeypatch.setenv("TOX_PARALLEL_ENV", "py37-django22")
437+
monkeypatch.setenv("TOX_ENV_NAME", "py37-django22")
438438

439439
django_pytester.create_test_module(
440440
"""

0 commit comments

Comments
 (0)