Skip to content

Commit

Permalink
add a caveats section
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Jan 15, 2025
1 parent d5feb58 commit 6e7ccad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ You can install "pytest-run-parallel" via `pip`_ from `PyPI`_::
$ pip install pytest-run-parallel


Caveats
-------

Pytest itself is not thread-safe and it is not safe to share stateful pytest
fixtures or marks between threads. Existing tests relying on setting up mutable
state via a fixture will see the state shared between threads. Tests that
dynamically set marks or share marks will also likely not be thread-safe. See
the pytest documentation `for more detail <pytest-thread-safety>`_ and the
community-maintained `free threaded Python porting guide
<porting-guide-thread-safety>`_ for more detail about using pytest in a
multithreaded context on the free-threaded build of Python.about thread safety
in pytest.

We suggest marking tests that are incompatible with this plugin's current design
with ``@pytest.mark.thread_unsafe``.

Usage
-----

Expand Down Expand Up @@ -198,3 +214,5 @@ If you encounter any problems, please `file an issue`_ along with a detailed des
.. _`pip`: https://pypi.org/project/pip/
.. _`PyPI`: https://pypi.org/project
.. _`PEP703`: https://peps.python.org/pep-0703/
.. _`pytest-thread-safety`: https://docs.pytest.org/en/stable/explanation/flaky.html#thread-safety
.. _`porting-guide-thread-safety`: https://py-free-threading.github.io/porting/#pytest-is-not-thread-safe

0 comments on commit 6e7ccad

Please sign in to comment.