1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2025-01-11 08:56:14 +01:00

Avoid race conditions when running tests with xdist

This commit is contained in:
Miro Hrončok 2022-12-13 16:56:33 +01:00
parent f71dd2a238
commit 028ee0cfb4
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import os
import shutil import shutil
import pytest import pytest
@ -5,12 +6,15 @@ from utils import FIXTURES_DIR, TOX4
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def projdir(tmp_path, monkeypatch): def projdir(tmp_path, monkeypatch, worker_id):
pwd = tmp_path / "projdir" pwd = tmp_path / "projdir"
pwd.mkdir() pwd.mkdir()
for fname in "tox.ini", "setup.py": for fname in "tox.ini", "setup.py":
shutil.copy(FIXTURES_DIR / fname, pwd) shutil.copy(FIXTURES_DIR / fname, pwd)
monkeypatch.chdir(pwd) monkeypatch.chdir(pwd)
# https://github.com/pypa/pip/issues/5345#issuecomment-386424455
monkeypatch.setenv("XDG_CACHE_HOME",
os.path.expanduser(f"~/.cache/pytest-xdist-{worker_id}"))
return pwd return pwd

View File

@ -2,6 +2,8 @@
envlist = py36,py37,py38,py39,py310,py311 envlist = py36,py37,py38,py39,py310,py311
[testenv] [testenv]
passenv =
XDG_CACHE_HOME
deps = deps =
six six
py py