Skip to content

Commit

Permalink
Document how session.run fails, and how to handle failures (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiLeija committed Dec 26, 2021
1 parent d49ed74 commit b0750af
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions nox/sessions.py
Expand Up @@ -262,6 +262,16 @@ def run(
session.run('cmd', '/c', 'del', 'docs/modules.rst')
If ``session.run`` fails, it will stop the session and will not run the next steps.
Basically, this will raise a Python exception. Taking this in count, you can use a
``try...finally`` block for cleanup runs, that will run even if the other runs fail::
try:
session.run("coverage", "run", "-m", "pytest")
finally:
# Display coverage report even when tests fail.
session.run("coverage", "report")
:param env: A dictionary of environment variables to expose to the
command. By default, all environment variables are passed.
:type env: dict or None
Expand Down

0 comments on commit b0750af

Please sign in to comment.