Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd06b15

Browse files
authored
Add inline tabs on Running and Writing Tests page for commands on different systems (#1206)
Remove bit about running tests on Python 2.7
1 parent 2a6cbd2 commit cd06b15

File tree

1 file changed

+127
-18
lines changed

1 file changed

+127
-18
lines changed

testing/run-write-tests.rst

+127-18
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,117 @@ Running
1717

1818
The shortest, simplest way of running the test suite is the following command
1919
from the root directory of your checkout (after you have
20-
:ref:`built Python <compiling>`)::
20+
:ref:`built Python <compiling>`):
2121

22-
./python -m test
22+
.. tab:: Unix
2323

24-
You may need to change this command as follows throughout this section.
25-
On :ref:`most <mac-python.exe>` macOS systems, replace :file:`./python`
26-
with :file:`./python.exe`. On Windows, use :file:`python.bat`. If using
27-
Python 2.7, replace ``test`` with ``test.regrtest``.
24+
.. code-block:: shell
25+
26+
./python -m test
27+
28+
.. tab:: macOS
29+
30+
.. code-block:: shell
31+
32+
./python.exe -m test
33+
34+
This works on :ref:`most <mac-python.exe>` macOS systems.
35+
36+
.. tab:: Windows
37+
38+
.. code-block:: dosbatch
39+
40+
.\python.bat -m test
2841
2942
This will run the majority of tests, but exclude a small portion of them; these
3043
excluded tests use special kinds of resources: for example, accessing the
3144
Internet, or trying to play a sound or to display a graphical interface on
3245
your desktop. They are disabled by default so that running the test suite
3346
is not too intrusive. To enable some of these additional tests (and for
3447
other flags which can help debug various issues such as reference leaks), read
35-
the help text::
48+
the help text:
49+
50+
.. tab:: Unix
51+
52+
.. code-block:: shell
53+
54+
./python -m test -h
55+
56+
.. tab:: macOS
57+
58+
.. code-block:: shell
59+
60+
./python.exe -m test -h
3661
37-
./python -m test -h
62+
.. tab:: Windows
63+
64+
.. code-block:: dosbatch
65+
66+
.\python.bat -m test -h
3867
3968
If you want to run a single test file, simply specify the test file name
4069
(without the extension) as an argument. You also probably want to enable
41-
verbose mode (using ``-v``), so that individual failures are detailed::
70+
verbose mode (using ``-v``), so that individual failures are detailed:
71+
72+
.. tab:: Unix
73+
74+
.. code-block:: shell
75+
76+
./python -m test -v test_abc
77+
78+
.. tab:: macOS
79+
80+
.. code-block:: shell
4281
43-
./python -m test -v test_abc
82+
./python.exe -m test -v test_abc
83+
84+
.. tab:: Windows
85+
86+
.. code-block:: dosbatch
87+
88+
.\python.bat -m test -v test_abc
4489
4590
To run a single test case, use the ``unittest`` module, providing the import
46-
path to the test case::
91+
path to the test case:
92+
93+
.. tab:: Unix
94+
95+
.. code-block:: shell
96+
97+
./python -m unittest -v test.test_abc.TestABC_Py
98+
99+
.. tab:: macOS
47100

48-
./python -m unittest -v test.test_abc.TestABC_Py
101+
.. code-block:: shell
102+
103+
./python.exe -m unittest -v test.test_abc.TestABC_Py
104+
105+
.. tab:: Windows
106+
107+
.. code-block:: dosbatch
108+
109+
.\python.bat -m unittest -v test.test_abc.TestABC_Py
49110
50111
Some test modules also support direct invocation,
51-
which might be useful for IDEs and local debugging::
112+
which might be useful for IDEs and local debugging:
113+
114+
.. tab:: Unix
115+
116+
.. code-block:: shell
117+
118+
./python Lib/test/test_typing.py
52119
53-
./python Lib/test/test_typing.py
120+
.. tab:: macOS
121+
122+
.. code-block:: shell
123+
124+
./python.exe Lib/test/test_typing.py
125+
126+
.. tab:: Windows
127+
128+
.. code-block:: dosbatch
129+
130+
.\python.bat Lib/test/test_typing.py
54131
55132
But, there are several important notes:
56133

@@ -61,19 +138,51 @@ But, there are several important notes:
61138
most likely it does not support direct invocation.
62139

63140
If you have a multi-core or multi-CPU machine, you can enable parallel testing
64-
using several Python processes so as to speed up things::
141+
using several Python processes so as to speed up things:
142+
143+
.. tab:: Unix
144+
145+
.. code-block:: shell
65146
66-
./python -m test -j0
147+
./python -m test -j0
148+
149+
.. tab:: macOS
150+
151+
.. code-block:: shell
152+
153+
./python.exe -m test -j0
154+
155+
.. tab:: Windows
156+
157+
.. code-block:: dosbatch
158+
159+
.\python.bat -m test -j0
67160
68161
If you are running a version of Python prior to 3.3 you must specify the number
69162
of processes to run simultaneously (e.g. ``-j2``).
70163

71164
.. _strenuous_testing:
72165

73166
Finally, if you want to run tests under a more strenuous set of settings, you
74-
can run ``test`` as::
167+
can run ``test`` as:
168+
169+
.. tab:: Unix
170+
171+
.. code-block:: shell
172+
173+
./python -bb -E -Wd -m test -r -w -uall
174+
175+
.. tab:: macOS
176+
177+
.. code-block:: shell
178+
179+
./python.exe -bb -E -Wd -m test -r -w -uall
180+
181+
.. tab:: Windows
182+
183+
.. code-block:: dosbatch
75184
76-
./python -bb -E -Wd -m test -r -w -uall
185+
.\python.bat -bb -E -Wd -m test -r -w -uall
77186
78187
The various extra flags passed to Python cause it to be much stricter about
79188
various things (the ``-Wd`` flag should be ``-W error`` at some point, but the

0 commit comments

Comments
 (0)