Skip to content

Commit 3aba764

Browse files
committed
enh: relink and cleanup following brand guielines
1 parent a65a2ce commit 3aba764

File tree

2 files changed

+64
-33
lines changed

2 files changed

+64
-33
lines changed

tests/code-cov.md

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,44 @@ using code coverage effectively.
1010
A good practice is to ensure that every line of your code runs at least once
1111
during your test suite. This helps you:
1212

13-
- Identify untested parts of your codebase.
14-
- Catch bugs that might otherwise go unnoticed.
15-
- Build confidence in your software's stability.
13+
- **Identify untested parts:** Parts of your codebase that are not
14+
covered by tests.
15+
- **Catch bugs:** Bugs that might otherwise go unnoticed.
16+
- **Build confidence:** Confidence in your software's stability.
1617

1718
## Limitations of code coverage
1819

1920
While high code coverage is valuable, it has its limits:
2021

21-
- **Difficult-to-test code:** Some parts of your code might be challenging to
22-
test, either due to complexity or limited resources.
23-
- **Missed edge cases:** Running all lines of code doesnt guarantee that edge
24-
cases are handled correctly.
22+
- **Difficult-to-test code:** Some parts of your code might be
23+
challenging to test, either due to complexity or limited resources.
24+
- **Missed edge cases:** Running all lines of code doesn't guarantee
25+
that edge cases are handled correctly.
2526

2627
Ultimately, you should focus on how your package will be used and ensure your
2728
tests cover those scenarios adequately.
2829

2930
## Tools for analyzing Python package code coverage
3031

31-
Some common services for analyzing code coverage are [codecov.io](https://about.codecov.io/) and [coveralls.io](https://coveralls.io/). These projects are free for open source tools and will provide dashboards that tell you how much of your codebase is covered during your tests. We recommend setting up an account (on either CodeCov or Coveralls) and using it to keep track of your code coverage.
32+
Some common services for analyzing code coverage are
33+
[codecov.io](https://about.codecov.io/) and [coveralls.io](https://coveralls.io/).
34+
These projects are free for open source tools and provide dashboards that
35+
show how much of your codebase is covered during your tests. We recommend
36+
setting up an account (on either CodeCov or Coveralls) and using it to
37+
keep track of your code coverage.
3238

3339
:::{figure} ../images/code-cov-stravalib.png
3440
:height: 450px
3541
:alt: Screenshot of the code cov service - showing test coverage for the stravalib package. This image shows a list of package modules and the associated number of lines and % lines covered by tests. At the top of the image, you can see what branch is being evaluated and the path to the repository.
3642

37-
The CodeCov platform is a useful tool if you wish to track code coverage visually. Using it, you can not only get the same summary information that you can get with the **pytest-cov** extension. You can also see what lines are covered by your tests and which are not. Code coverage is useful for evaluating unit tests and/or how much of your package code is "covered". It, however, will not evaluate things like integration tests and end-to-end workflows.
43+
The CodeCov platform is a useful tool if you wish to track code coverage
44+
visually. Using it, you can get the same summary information that you can get
45+
with the **pytest-cov** extension. You can also see what lines are covered by
46+
your tests and which are not. Code coverage is useful for evaluating
47+
[unit tests](test-types.md#unit-tests) and/or how much of your package code
48+
is "covered". It, however, will not evaluate things like
49+
[integration tests](test-types.md#integration-tests) and
50+
[end-to-end workflows](test-types.md).
3851

3952
:::
4053

@@ -46,21 +59,38 @@ You can also create and upload typing reports to CodeCov.
4659

4760
## Exporting Local Coverage Reports
4861

49-
In addition to using services like CodeCov or Coveralls, you can generate local coverage reports directly using the **coverage.py** tool. This can be especially useful if you want to create reports in Markdown or HTML format for offline use or documentation.
62+
In addition to using services like CodeCov or Coveralls, you can generate
63+
local coverage reports directly using the **coverage.py** tool. This can be
64+
especially useful if you want to create reports in Markdown or HTML format for
65+
offline use or documentation.
5066

5167
To generate a coverage report in **Markdown** format, run:
5268

5369
```bash
54-
$ python -m coverage report --format=markdown
70+
python -m coverage report --format=markdown
5571
```
56-
This command will produce a Markdown-formatted coverage summary that you can easily include in project documentation or share with your team.
5772

58-
To generate an HTML report that provides a detailed, interactive view of which lines are covered, use:
73+
This command will produce a Markdown-formatted coverage summary that you can
74+
include in project documentation or share with your team.
75+
76+
To generate an HTML report that provides a detailed, interactive view of which
77+
lines are covered, use:
5978

6079
```bash
6180
python -m coverage html
6281
```
6382

64-
The generated HTML report will be saved in a directory named htmlcov by default. Open the index.html file in your browser to explore your coverage results.
83+
The generated HTML report will be saved in a directory named `htmlcov` by
84+
default. Open the `index.html` file in your browser to explore your coverage
85+
results.
86+
87+
These local reports are an excellent way to quickly review coverage without
88+
setting up an external service.
89+
90+
## Next steps
6591

66-
These local reports are an excellent way to quickly review coverage without setting up an external service.
92+
Writing meaningful tests is the foundation of useful coverage.
93+
See [Write tests](write-tests.md) and [Test types](test-types.md)
94+
to design strong test suites. Run coverage regularly both
95+
[locally](run-tests.md) and in [continuous integration](tests-ci.md)
96+
to track progress over time.

tests/index.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ In this section, you will learn more about the importance of writing
99
tests for your Python package and how you can set up infrastructure
1010
to run your tests both locally and on GitHub.
1111

12-
1312
:::::{grid} 1 1 3 2
1413
:class-container: text-center
1514
:gutter: 3
@@ -20,9 +19,8 @@ to run your tests both locally and on GitHub.
2019
:link-type: doc
2120
:class-card: left-aligned
2221

23-
Learn more about the art of writing tests for your Python package.
24-
Learn about why you should write tests and how they can help you and
25-
potential contributors to your project.
22+
Learn about the importance of writing tests for your Python
23+
package and how they help you and potential contributors.
2624
:::
2725
::::
2826

@@ -32,8 +30,8 @@ potential contributors to your project.
3230
:link-type: doc
3331
:class-card: left-aligned
3432

35-
There are three general types of tests that you can write for your Python
36-
package: unit tests, integration tests and end-to-end (or functional) tests. Learn about all three.
33+
Understand the three test types: unit, integration, and
34+
end-to-end tests. Learn when and how to use each.
3735
:::
3836
::::
3937

@@ -43,8 +41,8 @@ package: unit tests, integration tests and end-to-end (or functional) tests. Lea
4341
:link-type: doc
4442
:class-card: left-aligned
4543

46-
If you expect your users to use your package across different versions
47-
of Python, then using an automation tool such as nox to run your tests is useful. Learn about the various tools that you can use to run your tests across python versions here.
44+
Learn about testing tools like pytest, nox, and tox to run
45+
tests across different Python versions on your computer.
4846
:::
4947
::::
5048

@@ -54,21 +52,23 @@ of Python, then using an automation tool such as nox to run your tests is useful
5452
:link-type: doc
5553
:class-card: left-aligned
5654

57-
Continuous integration platforms such as GitHub Actions can be
58-
useful for running your tests across both different Python versions
59-
and different operating systems. Learn about setting up tests to run in Continuous Integration here.
55+
Set up continuous integration with GitHub Actions to run
56+
tests across Python versions and operating systems.
6057
:::
6158
::::
6259

63-
:::::
64-
65-
66-
:::{figure-md} fig-target
67-
68-
<img src="../images/packaging-lifecycle.png" alt="" width="800px">
60+
::::{grid-item}
61+
:::{card} ✨ Code coverage ✨
62+
:link: code-cov
63+
:link-type: doc
64+
:class-card: left-aligned
6965

70-
Graphic showing the elements of the packaging process.
66+
Measure how much of your package code runs during tests.
67+
Learn to generate local reports and visualize coverage online.
7168
:::
69+
::::
70+
71+
:::::
7272

7373
```{toctree}
7474
:hidden:
@@ -79,6 +79,7 @@ Intro <self>
7979
Write tests <write-tests>
8080
Test types <test-types>
8181
Run tests locally <run-tests>
82+
Run tests with Nox <run-tests-nox>
8283
Run tests online (using CI) <tests-ci>
8384
Code coverage <code-cov>
8485
```

0 commit comments

Comments
 (0)