Skip to content

Nox

Nox is a command-line tool that automates tasks like testing and linting in isolated virtual environments across one or more Python versions. You define sessions as Python functions in a noxfile.py, and Nox creates an environment for each session, installs dependencies, and runs your commands.

Installation and Setup

Install it from PyPI:

Language: Windows PowerShell
(venv) PS> py -m pip install nox
Language: Shell
(venv) $ python -m pip install nox

Key Features

  • Defines functions in noxfile.py using @nox.session decorator.
  • Creates isolated environments per session using a selectable backend. It defaults to virtualenv, but supports uv, Conda, mamba, micromamba, rattler, and venv.
  • Runs sessions across multiple Python versions and filters by Python version at the CLI with --python.
  • Downloads missing Python interpreters on demand with --download-python, using uv or python-build-standalone, so a session’s Python version doesn’t have to be preinstalled.
  • Builds test matrices with nox.parametrize, including readable IDs.
  • Filters which sessions run using pytest-style keywords (-k/--keywords) and tags (-t/--tags).
  • Reuses environments between runs with --reuse-venv=yes (or -r) to speed up local workflows.
  • Runs independent sessions concurrently with -j/--parallel, which individual sessions opt into with @nox.session(allow_parallel=True).
  • Supports optional helpers like nox-poetry and nox-uv for tighter integration with Poetry and uv workflows.

Usage

Create a noxfile.py in your project directory and define sessions with an optional list of Python versions:

Language: Python
import nox

@nox.session(python=["3.12", "3.13", "3.14"])
def tests(session):
    session.install("pytest")
    session.run("pytest", "-q")

Run all sessions:

Language: Shell
$ nox

List available sessions:

Language: Shell
$ nox -l

Select sessions to run:

Language: Shell
$ nox -s lint tests

Choose Python versions at the CLI:

Language: Shell
$ nox --python 3.12

Reuse environments to speed up local runs:

Language: Shell
$ nox --reuse-venv=yes

Switch the default backend, with optional fallbacks:

Language: Shell
$ nox --default-venv-backend "uv|virtualenv"
Effective Python Testing With Pytest

Course

Testing Your Code With pytest

In this video course, you'll learn how to take your testing to the next level with pytest. You'll cover intermediate and advanced pytest features such as fixtures, marks, parameters, and plugins. With pytest, you can make your test suites fast, effective, and less painful to maintain.

intermediate testing tools

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 12, 2026