diff options
author | Miro HronĨok <miro@hroncok.cz> | 2023-04-13 20:53:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 11:53:38 -0700 |
commit | 02901007d8fba21de4ebc486f9692c56c8728af8 (patch) | |
tree | a4948c4dcad9b4381a94354ec2b7bf0520867fd6 | |
parent | ea169d0b200ab78b4dee95374127cf4491219284 (diff) | |
download | tox-git-02901007d8fba21de4ebc486f9692c56c8728af8.tar.gz |
Avoid race conditions in tests using the demo_pkg_inline fixture (#2986)
-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() |