Skip to content

Document tmp_path fixture does not support concurrent runs of the same test by default #11790

@faph

Description

@faph

The tmp_path fixture documentation (https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-tmp-path-fixture) states that temporary directories are unique for each "test invocation". This is correct in the sense that each test function is associated by a single unique temporary directory.

However, this is not correct when considering running the same test function concurrently by distinct pytest invocations. We are doing this all the time using Tox where tests are executed from multiple virtualenvs (different Python versions), concurrently.

In that scenario, the tmp_path generated directory is shared/clashes between multiple invocations.

I appreciate that the solution is to uniqueify the temp path prefix, similar to what the pytest-xdist extension does. With Tox, that is trivial to achieve. Reading the Pytest docs, I do not necessarily know that I need that solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortype: docsdocumentation improvement, missing or needing clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions