-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnoxfile.py
65 lines (49 loc) · 1.73 KB
/
noxfile.py
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
from pathlib import Path
import nox
from nox import Session, session
python_versions = ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
nox.options.sessions = ['tests', 'docs']
nox.options.reuse_existing_virtualenvs = True
@session(python=python_versions)
@nox.parametrize('old', [False, True])
def tests(session: Session, old: bool) -> None:
"""Run the tests."""
args = session.posargs or ['--buffer']
session.install('--upgrade', 'pip', 'setuptools', 'wheel', 'coverage')
session.install('-e', '.')
if old:
# Oldest supported versions
session.install('docutils==0.12', 'sphinxcontrib-napoleon==0.7.0')
if session.python in ['3.7']:
session.install(
'typing_extensions==3.7.4', 'typing_inspect==0.5.0'
)
coverage_file = f'.coverage.{session.python}.oldest'
else:
coverage_file = f'.coverage.{session.python}'
try:
session.run(
'coverage',
'run',
'--module',
'unittest',
*args,
env={'COVERAGE_FILE': coverage_file},
)
finally:
if session.interactive:
session.notify('coverage', posargs=[])
@session
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ['report', '--show-missing']
session.install('coverage')
if not session.posargs and any(Path().glob('.coverage.*')):
session.run('coverage', 'combine')
session.run('coverage', *args)
@session
def docs(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ['-b', 'html', 'doc/source', 'doc/build']
session.install('-e', '.[docs]')
session.run('sphinx-build', *args)