@@ -18,19 +18,30 @@ A simple pytest plugin to run tests concurrently
18
18
19
19
----
20
20
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/
22
32
23
33
24
34
Features
25
35
--------
26
36
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
28
39
29
40
30
41
Requirements
31
42
------------
32
43
33
- * TODO
44
+ `` pytest-run-parallel `` depends exclusively on `` pytest ``.
34
45
35
46
36
47
Installation
@@ -44,7 +55,46 @@ You can install "pytest-run-parallel" via `pip`_ from `PyPI`_::
44
55
Usage
45
56
-----
46
57
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
48
98
49
99
Contributing
50
100
------------
@@ -62,15 +112,10 @@ Issues
62
112
63
113
If you encounter any problems, please `file an issue `_ along with a detailed description.
64
114
65
- .. _`Cookiecutter` : https://github.com/audreyr/cookiecutter
66
- .. _`@hackebrot` : https://github.com/hackebrot
67
115
.. _`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
72
116
.. _`file an issue` : https://github.com/Quansight-Labs/pytest-run-parallel/issues
73
117
.. _`pytest` : https://github.com/pytest-dev/pytest
74
118
.. _`tox` : https://tox.readthedocs.io/en/latest/
75
119
.. _`pip` : https://pypi.org/project/pip/
76
120
.. _`PyPI` : https://pypi.org/project
121
+ .. _`PEP703` : https://peps.python.org/pep-0703/
0 commit comments