Skip to content

Commit 61e26c1

Browse files
lwasserZeitsperre
andcommitted
Fix: review fixes from Trevor
Co-authored-by: Trevor James Smith <[email protected]> Fix: edit from trevor Co-authored-by: Trevor James Smith <[email protected]> Fix: edit from trevor Co-authored-by: Trevor James Smith <[email protected]> Fix: edits from Trevor Co-authored-by: Trevor James Smith <[email protected]> Fix: edits from Nick Co-authored-by: Nick Murphy <[email protected]> Packaging image Fix: remove unused block Fix Update ci-tests-data/tests-ci.md Co-authored-by: Trevor James Smith <[email protected]>
1 parent 3248aae commit 61e26c1

File tree

5 files changed

+28
-33
lines changed

5 files changed

+28
-33
lines changed

ci-tests-data/ci.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If you are using GitLab CI/CD many of the principles described here will apply,
4747
### If you aren't sure, use GitHub Actions
4848

4949
While you are welcome to use the continuous integration platform of your choice,
50-
we recommend Github actions because it is free-to-use and integrated tightly
50+
we recommend GitHub Actions because it is free-to-use and integrated tightly
5151
into the GitHub user interface. There is also an entire store of GitHub action
5252
templates that you can easily use and adapt to your own needs.
5353

ci-tests-data/code-cov.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
Code coverage is the amount of your package's codebase that is run as a part of running your project's tests. A good rule of thumb is to ensure that every line of your code is run at least once during testing. However, note that good code coverage does not guarantee that your package is well-tested. For example, you may run all of your lines of code, but not account for many edge-cases that users may have. Ultimately, you should think carefully about the way your package will be used, and decide whether your tests adequately cover all of that usage.
44

5-
A common service for analyzing code coverage is [codecov.io](https://codecov.io/). This project is 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, and using codecov to keep track of your code coverage.
5+
Some common services for analyzing code coverage are [codecov.io](https://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.
66

77
```{figure} ../images/code-cov-stravalib.png
88
:height: 450px
99
:alt: Screenshot of the code cov service - showing test coverage for the stravalib package. in this image you can see 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 being shown.
1010
11-
the Code cov platform is a useful tool if you wish to visually track code coverage. Using it you can not only get the same summary information that you can get with **pytest-cov** extension. You can also get a visual representation of what lines are covered by your tests and what lines are not covered. Code cove is mostly 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.
11+
The CodeCov platform is a useful tool if you wish to visually track code coverage. Using it you can not only get the same summary information that you can get with **pytest-cov** extension. You can also get a visual representation of what lines are covered by your tests and what lines are not covered. Code coverage is mostly 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.
1212
1313
```

ci-tests-data/index.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Tests and data for your Python package
22

33
In this section you will learn more about the importance of writing
4-
tests for you Python package.
4+
tests for your Python package.
5+
6+
7+
:::{figure-md} fig-target
8+
9+
<img src="../images/packaging-lifecycle.png" alt="" width="800px">
10+
11+
Fix-- highlight the tests part of the circle and make everything else grey / not colored??
12+
:::
13+
14+
515

616
::::{grid} 1 1 2 2
717
:class-container: text-center

ci-tests-data/run-tests.md

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ calling:
4848

4949
`pytest`
5050

51-
Or if you want to run a specific test file - let's call such file - filename.py - you can run:
51+
Or if you want to run a specific test file - let's call this file "filename.py" - you can run:
5252

5353
`pytest filename.py`
5454

@@ -67,17 +67,17 @@ in various Python environments.
6767

6868
### Tools to automate running your tests
6969

70-
To run tests on various Python versions or in various specific environments with a single command, you can use an automation tool such as nox or tox.
71-
Both nox and tox can create an isolated virtual environment that you define. This allows you to easily run your tests in multiple environments and across Python versions.
70+
To run tests on various Python versions or in various specific environments with a single command, you can use an automation tool such as `nox` or `tox`.
71+
Both `nox` and `tox` can create an isolated virtual environment that you define. This allows you to easily run your tests in multiple environments and across Python versions.
7272

73-
We will focus on [Nox](https://nox.thea.codes/) in this guide. nox is a Python-based automation tool that builds upon the features of both Make and Tox. Nox is designed to simplify and streamline testing and development workflows. Everything that you do with nox can be implemented using a Python-based interface.
73+
We will focus on [Nox](https://nox.thea.codes/) in this guide. `nox` is a Python-based automation tool that builds upon the features of both `make` and `tox`. `nox` is designed to simplify and streamline testing and development workflows. Everything that you do with `nox` can be implemented using a Python-based interface.
7474

7575
```{admonition} Other automation tools you'll see in the wild
7676
:class: note
7777
7878
- **[Tox](https://tox.wiki/en/latest/index.html#useful-links)** is an automation tool that supports common steps such as building documentation, running tests across various versions of Python, and more. You can find [a nice overview of tox in the plasmaPy documentation](https://docs.plasmapy.org/en/stable/contributing/testing_guide.html#using-tox).
7979
80-
- **[Hatch](https://github.com/ofek/hatch)** is a modern end-to-end packaging tool that works with the popular build backend called hatchling. Hatch offers a tox-like setup where you can run tests locally using different Python versions. If you are using hatch to support your packaging workflow, you may want to also use its testing capabilities rather than using nox.
80+
- **[Hatch](https://github.com/ofek/hatch)** is a modern end-to-end packaging tool that works with the popular build backend called hatchling. `hatch` offers a `tox`-like setup where you can run tests locally using different Python versions. If you are using `hatch` to support your packaging workflow, you may want to also use its testing capabilities rather than using `nox`.
8181
8282
* [**make:**](https://www.gnu.org/software/make/manual/make.html) Some developers use Make, which is a build automation tool, for running tests
8383
due to its versatility; it's not tied to a specific language and can be used
@@ -93,17 +93,17 @@ with it. Make also won't manage environments for you like **nox** will do.
9393
- Python-based making it accessible if you already know Python and
9494
- It will create isolated environments to run workflows.
9595

96-
Nox simplifies creating and managing testing environments. With Nox, you can
96+
`nox` simplifies creating and managing testing environments. With `nox`, you can
9797
set up virtual environments, and run tests across Python versions using the environment manager of your choice with a
9898
single command.
9999

100100
Nox can also be used for other development tasks such as building
101101
documentation, creating your package distribution, and testing across various
102-
environment managers such as conda and pip.
102+
environment managers such as `conda` and `pip`.
103103

104104
## Test Environments
105105

106-
By default, Nox uses the Python built in `venv` environment manager. A virtual environment (`venv`) is a self-contained Python environment that allows you to isolate and manage dependencies for different Python projects. It helps ensure that project-specific libraries and packages do not interfere with each other, promoting a clean and organized development environment.
106+
By default, `nox` uses the Python built in `venv` environment manager. A virtual environment (`venv`) is a self-contained Python environment that allows you to isolate and manage dependencies for different Python projects. It helps ensure that project-specific libraries and packages do not interfere with each other, promoting a clean and organized development environment.
107107

108108
An example of using nox to run tests in `venv` environments for Python versions 3.9, 3.10 and 3.11 is below.
109109

@@ -119,8 +119,8 @@ TODO: add some tests above and show what the output would look like in the examp
119119

120120
Below is an example of setting up nox to run tests using `venv` which is the built in environment manager that comes with base Python.
121121

122-
Note that the example below assumes that you have setup your pyproject.toml to declare test dependencies in a way that pip
123-
can understand. And example of that setup is below.
122+
Note that the example below assumes that you have [setup your `pyproject.toml` to declare test dependencies in a way that pip
123+
can understand](../package-structure-code/declare-dependencies.md). And example of that setup is below.
124124

125125
```toml
126126
[project]
@@ -173,7 +173,7 @@ Note that unlike venv, conda can automatically install
173173
the various versions of Python that you need. You won't need to install all three Python versions if you use conda/mamba, like you do with `venv`.
174174

175175
```{note}
176-
For conda to work with nox, you will need to
176+
For `conda` to work with `nox`, you will need to
177177
install a conda-friendly version of Python. We suggest
178178
the mamba-forge installation.
179179
@@ -202,19 +202,3 @@ To run the above session you'd use:
202202
```bash
203203
nox -s test_mamba
204204
```
205-
206-
## IGNORE ME - testing doctest (not working now)
207-
208-
```{testcode}
209-
a = 1+2
210-
print(a)
211-
```
212-
213-
```{testoutput}
214-
215-
```
216-
217-
TODO: might be able to use doctest to run examples However so far it's not working as intended and may be extra work.
218-
https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html
219-
220-
---

ci-tests-data/tests-ci.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ jobs:
4949
python-version: ["3.9", "3.10", "3.11"]
5050

5151
steps:
52-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v4
5353
with:
5454
# fetch more than the last single commit to help scm generate proper version
5555
fetch-depth: 20
5656
- name: Set up Python ${{ matrix.python-version }}
5757
uses: actions/setup-python@v4
5858
with:
5959
python-version: ${{ matrix.python-version }}
60+
cache: pip # By adding cache here, you are telling actions to reuse installed dependencies rather than re-downloading and installing them each time. This speeds up your workflow
6061

6162
# This step and the step below are an optional steps to cache variables to make your build faster / more efficient
6263
- name: Set Variables
@@ -73,7 +74,7 @@ jobs:
7374
- name: Install dependencies
7475
run: |
7576
python -m pip install --upgrade pip
76-
pip install nox
77+
python -m pip install nox
7778
- name: List installed packages
7879
run: pip list
7980
- name: Run tests with pytest & nox

0 commit comments

Comments
 (0)