|
3 | 3 | :og:title: Run tests for your Python package across Python versions |
4 | 4 | ``` |
5 | 5 |
|
6 | | -# Run your tests |
| 6 | +# Run Python package tests |
7 | 7 |
|
8 | 8 | Running your tests is important to ensure that your package |
9 | 9 | is working as expected. It's good practice to consider that tests will run on your computer and your users' computers that may be running a different Python version and operating systems. Think about the following when running your tests: |
@@ -155,6 +155,10 @@ Nox can also be used for other development tasks such as building |
155 | 155 | documentation, creating your package distribution, and testing installations |
156 | 156 | across both PyPI related environments (e.g. venv, virtualenv) and `conda` (e.g. `conda-forge`). |
157 | 157 |
|
| 158 | +To get started with nox, you create a `noxfile.py` file at the root of your |
| 159 | +project directory. You then define commands using Python functions. |
| 160 | +Some examples of that are below. |
| 161 | + |
158 | 162 | ## Test Environments |
159 | 163 |
|
160 | 164 | 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. |
@@ -199,6 +203,7 @@ Notice that below one single nox session allows you to run |
199 | 203 | your tests on 4 different Python environments (Python 3.9, 3.10, 3.11, and 3.12). |
200 | 204 |
|
201 | 205 | ```python |
| 206 | +# This code would live in a noxfile.py file located at the root of your project directory |
202 | 207 | import nox |
203 | 208 |
|
204 | 209 | # For this to run you will need to have python3.9, python3.10 and python3.11 installed on your computer. Otherwise nox will skip running tests for whatever versions are missing |
@@ -235,13 +240,11 @@ the various versions of Python that you need. You won't need to install all four |
235 | 240 |
|
236 | 241 | ```{note} |
237 | 242 | For `conda` to work with `nox`, you will need to |
238 | | -install a conda-friendly version of Python. We suggest |
239 | | -the mamba-forge installation. |
240 | | -
|
241 | | -More on that here...<link to tutorial??> |
| 243 | +ensure that either `conda` or `mamba` is installed on your computer. |
242 | 244 | ``` |
243 | 245 |
|
244 | 246 | ```python |
| 247 | +# This code should live in your noxfile.py file |
245 | 248 | import nox |
246 | 249 |
|
247 | 250 | # The syntax below allows you to use mamba / conda as your environment manager, if you use this approach you don’t have to worry about installing different versions of Python |
|
0 commit comments