Skip to content

Commit 40d6473

Browse files
authored
Add inline tabs on Increase Test Coverage page for commands on different systems (#1228)
1 parent 6d96e57 commit 40d6473

File tree

1 file changed

+68
-18
lines changed

1 file changed

+68
-18
lines changed

testing/coverage.rst

+68-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
Increase test coverage
55
======================
66

7+
.. raw:: html
8+
9+
<script>
10+
document.addEventListener('DOMContentLoaded', function() {
11+
activateTab(getOS());
12+
});
13+
</script>
14+
715
Python development follows a practice that all semantic changes and additions
816
to the language and :abbr:`stdlib (standard library)` are accompanied by
917
appropriate unit tests. Unfortunately Python was in existence for a long time
@@ -87,23 +95,35 @@ just built, and this built version of Python will not see packages installed
8795
into your default version of Python. One option is to use a virtual environment
8896
to install coverage.
8997

90-
On Unix run::
98+
.. tab:: Unix
99+
100+
Run:
101+
102+
.. code-block:: shell
103+
104+
./python -m venv ../cpython-venv
105+
source ../cpython-venv/bin/activate
106+
pip install coverage
107+
108+
.. tab:: macOS
91109

92-
./python -m venv ../cpython-venv
93-
source ../cpython-venv/bin/activate
94-
pip install coverage
110+
On :ref:`most <mac-python.exe>` macOS systems run:
95111

96-
On :ref:`most <mac-python.exe>` macOS systems run::
112+
.. code-block:: shell
97113
98-
./python.exe -m venv ../cpython-venv
99-
source ../cpython-venv/bin/activate
100-
pip install coverage
114+
./python.exe -m venv ../cpython-venv
115+
source ../cpython-venv/bin/activate
116+
pip install coverage
101117
102-
On Windows run::
118+
.. tab:: Windows
103119

104-
python.bat -m venv ..\\cpython-venv
105-
..\\cpython-venv\\Scripts\\activate.bat
106-
pip install coverage
120+
Run:
121+
122+
.. code-block:: dosbatch
123+
124+
python.bat -m venv ..\\cpython-venv
125+
..\\cpython-venv\\Scripts\\activate.bat
126+
pip install coverage
107127
108128
You can now use python without the ./ for the rest of these instructions, as
109129
long as your venv is activated. For more info on venv see `Virtual Environment
@@ -231,19 +251,49 @@ Measuring coverage of C code with gcov and lcov
231251

232252
It's also possible to measure the function, line and branch coverage of
233253
Python's C code. Right now only GCC with `gcov`_ is supported. In order to
234-
create an instrumented build of Python with gcov, run::
254+
create an instrumented build of Python with gcov, run:
255+
256+
.. tab:: Unix/macOS
257+
258+
.. code-block:: shell
259+
260+
make coverage
261+
262+
.. tab:: Windows
235263

236-
make coverage
264+
.. code-block:: dosbatch
265+
266+
.\make coverage
237267
238268
Then run some code and gather coverage data with the ``gcov`` command. In
239-
order to create a HTML report you can install `lcov`_. The command::
269+
order to create a HTML report you can install `lcov`_. The command:
270+
271+
.. tab:: Unix/macOS
272+
273+
.. code-block:: shell
274+
275+
make coverage-lcov
276+
277+
.. tab:: Windows
278+
279+
.. code-block:: dosbatch
240280
241-
make coverage-lcov
281+
.\make coverage-lcov
242282
243283
assembles coverage data, removes 3rd party and system libraries and finally
244-
creates a report. You can skip both steps and just run::
284+
creates a report. You can skip both steps and just run:
285+
286+
.. tab:: Unix/macOS
287+
288+
.. code-block:: shell
289+
290+
make coverage-report
291+
292+
.. tab:: Windows
293+
294+
.. code-block:: dosbatch
245295
246-
make coverage-report
296+
.\make coverage-report
247297
248298
if you like to generate a coverage report for Python's stdlib tests. It takes
249299
about 20 to 30 minutes on a modern computer.

0 commit comments

Comments
 (0)