diff options
-rw-r--r-- | docs/changelog/2985.bugfix.rst | 1 | ||||
-rw-r--r-- | tests/conftest.py | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/docs/changelog/2985.bugfix.rst b/docs/changelog/2985.bugfix.rst new file mode 100644 index 00000000..da609dcb --- /dev/null +++ b/docs/changelog/2985.bugfix.rst @@ -0,0 +1 @@ +Avoid race conditions in tests using the ``demo_pkg_inline`` fixture. diff --git a/tests/conftest.py b/tests/conftest.py index b3086268..c7982db8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,7 @@ import pytest from _pytest.monkeypatch import MonkeyPatch # cannot import from tox.pytest yet from _pytest.tmpdir import TempPathFactory from distlib.scripts import ScriptMaker +from filelock import FileLock from pytest_mock import MockerFixture from virtualenv import cli_run @@ -77,8 +78,10 @@ def demo_pkg_setuptools() -> Path: @pytest.fixture(scope="session") -def demo_pkg_inline() -> Path: - return HERE / "demo_pkg_inline" +def demo_pkg_inline() -> Iterator[Path]: + demo_path = HERE / "demo_pkg_inline" + with FileLock(f"{demo_path}.lock"): + yield demo_path @pytest.fixture() |