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
Copy file name to clipboardExpand all lines: tests/run-tests.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,12 @@ Python versions.
13
13
14
14
There are three types of tools that will make is easier to setup and run your tests in various environments:
15
15
16
-
1. A **test framework**, is a package that provides a particular syntax and set of tools for _both writing and running your tests_. Some test frameworks also have plugins that add additional features such as evaluating how much of your code the tests cover. Below you will learn about the **pytest** framework which is one of the most commonly used Python testing frameworks in the scientific ecosystem. Testing frameworks are essential but they only serve to run your tests. They won't allow you to run tests across Python versions without additional automation tools (see automation tools below).
16
+
1. A **test framework**, is a package that provides a particular syntax and set of tools for _both writing and running your tests_. Some test frameworks also have plugins that add additional features such as evaluating how much of your code the tests cover. Below you will learn about the **pytest** framework which is one of the most commonly used Python testing frameworks in the scientific ecosystem. Testing frameworks are essential but they only serve to run your tests. They don't provide a way to easily run tests across Python versions without additional automation tools (see automation tools below).
17
17
2.**Automation tools** allow you to automate running workflows such as tests in specific ways using user-defined commands. For instance it's useful to be able to run tests across different Python versions with a single command. Tools such as [**nox**](https://nox.thea.codes/en/stable/index.html) and [**tox**](https://tox.wiki/en/latest/index.html) also allow you to run tests across Python versions. However, it will be difficult to test your build on different operating systems using only nox and tox - this is where continuous integration (CI) comes into play.
18
18
3.**Continuous Integration (CI):** is the last tool that you'll need to run your tests. CI will not only allow you to replicate any automated builds you create using nox or tox to run your package in different Python environments. It will also allow you to run your tests on different operating systems (Windows, Mac and Linux). [We discuss using CI to run tests here](tests-ci).
19
19
20
20
:::{figure-md}
21
-

21
+

22
22
23
23
There are three types of tools that will help you develop and run your tests. Test frameworks like pytest
24
24
provide syntax and a **framework** for you to write and
@@ -48,9 +48,9 @@ calling:
48
48
49
49
`pytest`
50
50
51
-
Or if you want to run a specific test file - let's call this file "filename.py" - you can run:
51
+
Or if you want to run a specific test file - let's call this file "test_module.py" - you can run:
52
52
53
-
`pytest filename.py`
53
+
`pytest test_module.py`
54
54
55
55
Learn more from the [get started docs here](https://docs.pytest.org/en/7.1.x/getting-started.html).
56
56
@@ -88,10 +88,10 @@ with it. Make also won't manage environments for you like **nox** will do.
88
88
89
89
## Run tests across Python versions with nox
90
90
91
-
**Nox** is a great automation tool to learn give it is:
91
+
**Nox** is a great automation tool to learn because it:
92
92
93
-
- Python-based making it accessible if you already know Python and
94
-
-It will create isolated environments to run workflows.
93
+
-Is Python-based making it accessible if you already know Python and
94
+
-Will create isolated environments to run workflows.
95
95
96
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
@@ -105,10 +105,10 @@ environment managers such as `conda` and `pip`.
105
105
106
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
-
An example of using nox to run tests in `venv` environments for Python versions 3.9, 3.10and 3.11 is below.
108
+
An example of using nox to run tests in `venv` environments for Python versions 3.9, 3.10, 3.11 and 3.12 is below.
109
109
110
110
```{warning}
111
-
Note that for the code below to work, you need to have all 3 versions of Python installed on your computer for `venv` to find.
111
+
Note that for the code below to work, you need to have all 4 versions of Python installed on your computer for `nox` to find.
112
112
```
113
113
114
114
### Nox with venv environments
@@ -120,7 +120,7 @@ TODO: add some tests above and show what the output would look like in the examp
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
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.
123
+
can understand](../package-structure-code/declare-dependencies.md). An example of that setup is below.
0 commit comments