Skip to content

Commit da26e03

Browse files
harshit-s-gowdaStanFromIrelandzware
authored
Recommend running the test suite in parallel (#1917)
Co-authored-by: Stan Ulbrych <stan@python.org> Co-authored-by: Zachary Ware <zach@python.org>
1 parent dce8cdf commit da26e03

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎testing/run-write-tests.rst‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ Running and writing tests
1717
Running
1818
=======
1919

20-
The shortest, simplest way of running the test suite is the following command
21-
from the root directory of your checkout (after you have
22-
:ref:`built Python <compiling>`):
20+
The shortest, simplest way of running the test suite is the following command,
21+
which runs tests in parallel, from the root directory of your checkout
22+
(after you have :ref:`built Python <compiling>`):
2323

2424
.. tab:: Unix
2525

2626
.. code-block:: shell
2727
28-
./python -m test
28+
./python -m test -j0
2929
3030
.. tab:: macOS
3131

3232
.. code-block:: shell
3333
34-
./python.exe -m test
34+
./python.exe -m test -j0
3535
3636
This works on :ref:`most <mac-python.exe>` macOS systems.
3737

3838
.. tab:: Windows
3939

4040
.. code-block:: dosbatch
4141
42-
.\python.bat -m test
42+
.\python.bat -m test -j0
4343
4444
This will run the majority of tests, but exclude a small portion of them; these
4545
excluded tests use special kinds of resources: for example, accessing the
@@ -139,26 +139,31 @@ But, there are several important notes:
139139
In other words: if some module does not have ``unittest.main()``, then
140140
most likely it does not support direct invocation.
141141

142-
If you have a multi-core or multi-CPU machine, you can enable parallel testing
143-
using several Python processes so as to speed up things:
142+
By default, ``-j0`` runs tests in parallel using a number of worker processes
143+
based on the CPU count, which is much faster but can interleave output
144+
from different tests. To run tests sequentially, for example when debugging
145+
a failure, drop the ``-j`` flag:
144146

145147
.. tab:: Unix
146148

147149
.. code-block:: shell
148150
149-
./python -m test -j0
151+
./python -m test
150152
151153
.. tab:: macOS
152154

153155
.. code-block:: shell
154156
155-
./python.exe -m test -j0
157+
./python.exe -m test
156158
157159
.. tab:: Windows
158160

159161
.. code-block:: dosbatch
160162
161-
.\python.bat -m test -j0
163+
.\python.bat -m test
164+
165+
To limit how many tests run at once, pass an explicit number of
166+
worker processes instead, such as ``-j2``.
162167

163168
.. _strenuous_testing:
164169

0 commit comments

Comments
 (0)