|
1 | 1 | """Nox configuration file.""" |
2 | 2 |
|
| 3 | +import os |
| 4 | + |
3 | 5 | import nox |
4 | 6 |
|
| 7 | +nox.options.default_venv_backend = "uv" |
| 8 | + |
| 9 | +python = ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 10 | +num_cpus = os.cpu_count() or 1 |
| 11 | +xdist = ("-n", "auto") if num_cpus > 2 else () |
| 12 | + |
| 13 | + |
| 14 | +@nox.session(python=python) |
| 15 | +def pytest_min_deps(session: nox.Session) -> None: |
| 16 | + """Run pytest with no optional dependencies.""" |
| 17 | + session.install(".[test]") |
| 18 | + session.run("coverage", "erase") |
| 19 | + session.run("pytest", *xdist) |
| 20 | + |
5 | 21 |
|
6 | | -@nox.session(python=["3.9", "3.10", "3.11", "3.12"]) |
7 | | -@nox.parametrize("all_deps", [True, False]) |
8 | | -def pytest(session: nox.Session, all_deps: bool) -> None: |
9 | | - """Run pytest with optional dependencies.""" |
10 | | - session.install(".[testing,other]" if all_deps else ".[testing]") |
| 22 | +@nox.session(python=python) |
| 23 | +def pytest_all_deps(session: nox.Session) -> None: |
| 24 | + """Run pytest with "other" optional dependencies.""" |
| 25 | + session.install(".[test,other]") |
11 | 26 | session.run("coverage", "erase") |
12 | | - session.run("pytest") |
| 27 | + session.run("pytest", *xdist) |
13 | 28 |
|
14 | 29 |
|
15 | | -@nox.session(python="3.11") |
| 30 | +@nox.session(python="3.13") |
16 | 31 | def pytest_typeguard(session: nox.Session) -> None: |
17 | 32 | """Run pytest with typeguard.""" |
18 | | - session.install(".[testing,other]") |
| 33 | + session.install(".[test,other]") |
19 | 34 | session.run("coverage", "erase") |
20 | | - session.run("pytest", "--typeguard-packages=adaptive") |
| 35 | + session.run("pytest", "--typeguard-packages=adaptive", *xdist) |
21 | 36 |
|
22 | 37 |
|
23 | | -@nox.session(python="3.11") |
| 38 | +@nox.session(python="3.13") |
24 | 39 | def coverage(session: nox.Session) -> None: |
25 | 40 | """Generate coverage report.""" |
26 | | - session.install("coverage") |
27 | | - session.install(".[testing,other]") |
28 | | - session.run("pytest") |
| 41 | + session.install(".[test,other]") |
| 42 | + session.run("pytest", *xdist) |
29 | 43 |
|
30 | 44 | session.run("coverage", "report") |
31 | 45 | session.run("coverage", "xml") |
0 commit comments