Define and parametrize Nox sessions in a noxfile
Answer: By default, Nox looks for configuration in noxfile.py. Pass --noxfile when running nox if you want a different file. Nox sessions use standard Python functions, each decorated with @nox.session. In the example, tests calls session.run('pytest').
Defaults and descriptions
By default, all sessions will be run if no sessions are specified. Pass default=False in the @nox.session(...) decorator to drop a session from that list. The nox.options.sessions option can also name the default list. You can add a description to your session using a docstring. The first line will be shown when listing the sessions. The nox --list command will show available sessions. You can also configure sessions to run against multiple Python versions and parametrize sessions.
| noxfile.py | session | |---|---| | @nox.session | session.run | | nox.options.sessions | default=False | | docstring | nox --list | | parametrize | Python versions |
virtualenv
In the implementation, session.virtualenv is the virtualenv that all commands are run in. If a virtualenv has not been created for this session, that property raises. Session names used on disk are normalized to be a "safe" filesystem path for a virtualenv. A name that is too long may be hashed.
See also
Claims
- id: C1 claim: Nox reads noxfile.py by default and defines sessions with @nox.session. source: S1 evidence: "Nox sessions are configured via standard Python functions that are decorated"
- id: C2 claim: If no sessions are named, Nox runs all of them unless default=False or nox.options.sessions says otherwise. source: S1 evidence: "By default, all sessions will be run if no sessions are specified."
- id: C3 claim: The session object's virtualenv is the environment that all commands are run in. source: S2 evidence: "The virtualenv that all commands are run in."
Sources
- [S1] Configuration & API. Nox docs. https://nox.thea.codes/en/stable/config.html . License: Apache-2.0. Accessed 2026-11-19.
- [S2] sessions.py. Nox source. https://raw.githubusercontent.com/wntrblm/nox/main/nox/sessions.py . License: Apache-2.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Nox docs, Configuration & API; Nox source, sessions.py. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Nox docs, Configuration & API; Nox source, sessions.py. Apache-2.0; Apache-2.0.
Cite this
iinventedlight. 2026. "Define and parametrize Nox sessions in a noxfile." iinventedlight Library, iil:note:ybm6pq8w, version of 2026-11-19. https://iinventedlight.com/library/notes/nox-sessions/. License: CC-BY-4.0.
@misc{iil_note_ybm6pq8w,
author = {{iinventedlight}},
title = {{Define and parametrize Nox sessions in a noxfile}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/nox-sessions/},
note = {Permanent ID iil:note:ybm6pq8w. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- nox-sessions.table.json (table; CC-BY-4.0)
- nox-sessions.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/nox-sessions.md.