To allow more fine-grained session selection, allow tags to be set on individual parametrized sessions via either a tags argument to the @nox.parametrize() decorator, or a tags argument to nox.param() (similar to how parametrized session IDs can be specified). Any tags specified this way will be added to any tags passed to the @nox.session() decorator.
In this case, a developer could run nox -t sqlite to run just the tests with all versions of Django but only using the SQLite backend.
Here's a more complex example:
def generate_params():
for python in ["3.10", "3.11", 3.12"]:
for django in [3, 4, 5]:
tags = []
if python == "3.12" and django == 5:
tags.append("quick")
if python == "3.12" or django == 5:
tags.append("standard")
yield nox.param([python, django], tags)
@nox.session
@nox.parametrize(
["python", "django"], generate_params(),
)
def test(session, django):
pass
This tags the Python 3.12/Django 5 combination with the quick tag, allowing the developer to run a quick sanity check on the code using a single entry from the test matrix. It also tags any combination of Python 3.12 or Django 5 with the standard tag, allowing the developer to run the tests using Python 3.12 with all versions of Django along with all versions of Python with Django 5, which should give fairly comprehensive test coverage while only having to run five entries from the test matrix instead of nine.
To allow more fine-grained session selection, allow tags to be set on individual parametrized sessions via either a tags argument to the
@nox.parametrize()
decorator, or a tags argument tonox.param()
(similar to how parametrized session IDs can be specified). Any tags specified this way will be added to any tags passed to the@nox.session()
decorator.A couple of examples of how this could be used:
In this case, a developer could run
nox -t sqlite
to run just the tests with all versions of Django but only using the SQLite backend.Here's a more complex example:
This tags the Python 3.12/Django 5 combination with the
quick
tag, allowing the developer to run a quick sanity check on the code using a single entry from the test matrix. It also tags any combination of Python 3.12 or Django 5 with thestandard
tag, allowing the developer to run the tests using Python 3.12 with all versions of Django along with all versions of Python with Django 5, which should give fairly comprehensive test coverage while only having to run five entries from the test matrix instead of nine.