-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathnoxfile.py
More file actions
80 lines (63 loc) · 1.9 KB
/
Copy pathnoxfile.py
File metadata and controls
80 lines (63 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from collections.abc import Iterator
from contextlib import contextmanager
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.default_venv_backend = "uv"
PYPROJECT = nox.project.load_toml("pyproject.toml")
PYTHON_VERSIONS = nox.project.python_versions(PYPROJECT)
@nox.session(python="3.13")
def docs(session: nox.Session) -> None:
session.run_install("uv", "sync", "--no-default-groups", "--group=docstest")
temp_dir = session.create_tmp()
session.run(
"sphinx-build",
"-W",
"-b",
"html",
"-d",
f"{temp_dir}/doctrees",
"docs",
"docs/_build/html",
)
session.run("doc8", "docs/")
@nox.session(python=PYTHON_VERSIONS)
def tests(session: nox.Session) -> None:
session.run_install(
"uv",
"sync",
"--no-default-groups",
"--group=coverage",
"--group=test",
)
session.run("coverage", "run", "-m", "pytest", *session.posargs)
@nox.session(name="test-min-deps", python=PYTHON_VERSIONS)
def test_min_deps(session: nox.Session) -> None:
with restore_file("uv.lock"):
session.run_install(
"uv",
"sync",
"--no-default-groups",
"--group=test",
"--resolution=lowest-direct",
)
session.run("pytest", *session.posargs)
@nox.session(name="test-latest", python=PYTHON_VERSIONS)
def test_latest(session: nox.Session) -> None:
session.run_install(
"uv",
"sync",
"--no-default-groups",
"--group=test",
"--no-install-project",
)
session.run_install("uv", "pip", "install", "--upgrade", ".")
session.run("pytest", *session.posargs)
@contextmanager
def restore_file(path: str) -> Iterator[None]:
with open(path, "rb") as f:
original = f.read()
try:
yield
finally:
with open(path, "wb") as f:
f.write(original)