LinuxCommandLibrary

nox

TLDR

Run default session

$ nox
copy
Run specific session
$ nox -s [tests]
copy
List available sessions
$ nox -l
copy
Run with Python version
$ nox -p [3.11]
copy
Reuse existing virtualenv
$ nox -r
copy
Run with extra arguments
$ nox -- [pytest-args]
copy

SYNOPSIS

nox [options] [-- args]

DESCRIPTION

Nox is a Python automation tool similar to tox. It automates testing across multiple Python versions and manages virtual environments for test sessions.
Sessions are defined in noxfile.py using Python functions.

PARAMETERS

-s, --sessions name

Run specific sessions.
-l, --list
List sessions.
-r, --reuse-existing-virtualenvs
Reuse virtualenvs.
-p, --python version
Python version.
-f, --noxfile file
Nox configuration file.
-k expression
Filter sessions by keyword.

NOXFILE EXAMPLE

$ import nox

@nox.session(python=["3.9", "3.10", "3.11"])
def tests(session):
    session.install("pytest", ".")
    session.run("pytest")

@nox.session
def lint(session):
    session.install("flake8")
    session.run("flake8", "src")
copy

CAVEATS

Requires noxfile.py. Creates virtualenvs per session. Slower than direct pytest without -r.

HISTORY

Nox was created by Thea Flowers at Google as a more flexible alternative to tox, using Python for configuration.

SEE ALSO

tox(1), pytest(1), virtualenv(1)

Copied to clipboard