Skip to content

Commit 0290100

Browse files
authored
Avoid race conditions in tests using the demo_pkg_inline fixture (#2986)
1 parent ea169d0 commit 0290100

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

docs/changelog/2985.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid race conditions in tests using the ``demo_pkg_inline`` fixture.

tests/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from _pytest.monkeypatch import MonkeyPatch # cannot import from tox.pytest yet
1212
from _pytest.tmpdir import TempPathFactory
1313
from distlib.scripts import ScriptMaker
14+
from filelock import FileLock
1415
from pytest_mock import MockerFixture
1516
from virtualenv import cli_run
1617

@@ -77,8 +78,10 @@ def demo_pkg_setuptools() -> Path:
7778

7879

7980
@pytest.fixture(scope="session")
80-
def demo_pkg_inline() -> Path:
81-
return HERE / "demo_pkg_inline"
81+
def demo_pkg_inline() -> Iterator[Path]:
82+
demo_path = HERE / "demo_pkg_inline"
83+
with FileLock(f"{demo_path}.lock"):
84+
yield demo_path
8285

8386

8487
@pytest.fixture()

0 commit comments

Comments
 (0)