Skip to content

Commit 15b94d7

Browse files
committed
Improve README
1 parent f4ef7f2 commit 15b94d7

File tree

1 file changed

+55
-10
lines changed

1 file changed

+55
-10
lines changed

README.rst

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,30 @@ A simple pytest plugin to run tests concurrently
1818

1919
----
2020

21-
This `pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `cookiecutter-pytest-plugin`_ template.
21+
This `pytest`_ plugin takes a set of tests that would be normally be run
22+
serially and execute them in parallel.
23+
24+
The main goal of ``pytest-run-parallel`` is to discover thread-safety issues that
25+
could exist when using C libraries, this is of vital importance after `PEP703`_,
26+
which provides a path for a CPython implementation without depending on the
27+
Global Interpreter Lock (GIL), thus allowing for proper parallelism in programs
28+
that make use of the CPython interpreter.
29+
30+
For more information about C thread-safety issues, please visit the
31+
free-threaded community guide at https://py-free-threading.github.io/
2232

2333

2434
Features
2535
--------
2636

27-
* TODO
37+
* A global CLI flag ``--parallel-threads`` to run a test suite in parallel
38+
* A marker ``pytest.mark.parallel_threads`` to mark a single test to run in parallel
2839

2940

3041
Requirements
3142
------------
3243

33-
* TODO
44+
``pytest-run-parallel`` depends exclusively on ``pytest``.
3445

3546

3647
Installation
@@ -44,7 +55,46 @@ You can install "pytest-run-parallel" via `pip`_ from `PyPI`_::
4455
Usage
4556
-----
4657

47-
* TODO
58+
This plugin has two modes of operation, one via the ``--parallel-threads`` pytest
59+
CLI flag, which allows a whole test suite to be run in parallel:
60+
61+
.. code-block:: bash
62+
63+
pytest --parallel-threads=10 tests
64+
65+
By default, the value of ``parallel-threads`` will be 1, thus not modifying the
66+
usual behaviour of pytest except when the flag is set.
67+
68+
The other mode of operation occurs at the individual test level, via the
69+
``pytest.mark.parallel_threads`` marker:
70+
71+
.. code-block:: python
72+
73+
# test_file.py
74+
import pytest
75+
76+
@pytest.fixture
77+
def my_fixture():
78+
...
79+
80+
@pytest.mark.parallel_threads(2)
81+
def test_something_1():
82+
# This test will be run in parallel using two concurrent threads
83+
...
84+
85+
@pytest.mark.parametrize('arg', [1, 2, 3])
86+
@pytest.mark.parallel_threads(3)
87+
def test_fixutre(my_fixture, arg):
88+
# pytest markers and fixtures are supported as well
89+
...
90+
91+
Both modes of operations are supported simultaneously, i.e.,
92+
93+
.. code-block:: bash
94+
95+
# test_something_1 and test_fixutre will be run using their set number of
96+
# threads; other tests will be run using 5 threads.
97+
pytest -x -v --parallel-threads=5 test_file.py
4898
4999
Contributing
50100
------------
@@ -62,15 +112,10 @@ Issues
62112

63113
If you encounter any problems, please `file an issue`_ along with a detailed description.
64114

65-
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter
66-
.. _`@hackebrot`: https://github.com/hackebrot
67115
.. _`MIT`: https://opensource.org/licenses/MIT
68-
.. _`BSD-3`: https://opensource.org/licenses/BSD-3-Clause
69-
.. _`GNU GPL v3.0`: https://www.gnu.org/licenses/gpl-3.0.txt
70-
.. _`Apache Software License 2.0`: https://www.apache.org/licenses/LICENSE-2.0
71-
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin
72116
.. _`file an issue`: https://github.com/Quansight-Labs/pytest-run-parallel/issues
73117
.. _`pytest`: https://github.com/pytest-dev/pytest
74118
.. _`tox`: https://tox.readthedocs.io/en/latest/
75119
.. _`pip`: https://pypi.org/project/pip/
76120
.. _`PyPI`: https://pypi.org/project
121+
.. _`PEP703`: https://peps.python.org/pep-0703/

0 commit comments

Comments
 (0)