You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
Copy file name to clipboardExpand all lines: ci-tests-data/code-cov.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
3
3
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.
4
4
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.
6
6
7
7
```{figure} ../images/code-cov-stravalib.png
8
8
:height: 450px
9
9
: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.
10
10
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.
Copy file name to clipboardExpand all lines: ci-tests-data/run-tests.md
+11-27Lines changed: 11 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ calling:
48
48
49
49
`pytest`
50
50
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:
52
52
53
53
`pytest filename.py`
54
54
@@ -67,17 +67,17 @@ in various Python environments.
67
67
68
68
### Tools to automate running your tests
69
69
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.
72
72
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.
74
74
75
75
```{admonition} Other automation tools you'll see in the wild
76
76
:class: note
77
77
78
78
- **[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).
79
79
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`.
81
81
82
82
* [**make:**](https://www.gnu.org/software/make/manual/make.html) Some developers use Make, which is a build automation tool, for running tests
83
83
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.
93
93
- Python-based making it accessible if you already know Python and
94
94
- It will create isolated environments to run workflows.
95
95
96
-
Nox simplifies creating and managing testing environments. With Nox, you can
96
+
`nox` simplifies creating and managing testing environments. With `nox`, you can
97
97
set up virtual environments, and run tests across Python versions using the environment manager of your choice with a
98
98
single command.
99
99
100
100
Nox can also be used for other development tasks such as building
101
101
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`.
103
103
104
104
## Test Environments
105
105
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.
107
107
108
108
An example of using nox to run tests in `venv` environments for Python versions 3.9, 3.10 and 3.11 is below.
109
109
@@ -119,8 +119,8 @@ TODO: add some tests above and show what the output would look like in the examp
119
119
120
120
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.
121
121
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.
124
124
125
125
```toml
126
126
[project]
@@ -173,7 +173,7 @@ Note that unlike venv, conda can automatically install
173
173
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`.
174
174
175
175
```{note}
176
-
For conda to work with nox, you will need to
176
+
For `conda` to work with `nox`, you will need to
177
177
install a conda-friendly version of Python. We suggest
178
178
the mamba-forge installation.
179
179
@@ -202,19 +202,3 @@ To run the above session you'd use:
202
202
```bash
203
203
nox -s test_mamba
204
204
```
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.
Copy file name to clipboardExpand all lines: ci-tests-data/tests-ci.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -49,14 +49,15 @@ jobs:
49
49
python-version: ["3.9", "3.10", "3.11"]
50
50
51
51
steps:
52
-
- uses: actions/checkout@v3
52
+
- uses: actions/checkout@v4
53
53
with:
54
54
# fetch more than the last single commit to help scm generate proper version
55
55
fetch-depth: 20
56
56
- name: Set up Python ${{ matrix.python-version }}
57
57
uses: actions/setup-python@v4
58
58
with:
59
59
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
60
61
61
62
# This step and the step below are an optional steps to cache variables to make your build faster / more efficient
0 commit comments