-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
69 lines (53 loc) · 2.01 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
66
67
68
69
"""This module defines different "sessions"; each session tests certain aspects of
HydPy-MPR, some in a freshly set up virtual environment.
To execute all sessions, install `Nox`, open a command-line prompt, navigate to the
directory containing this nox file and write "nox". To run specific sessions, write,
for example:
nox -s doctest -s pylint
"""
import contextlib
import os
import shutil
from typing import *
from typing_extensions import assert_never
import nox
def _install_hydpy_mpr(session: nox.Session) -> None:
wheels = [
os.path.join("dist", fn) for fn in os.listdir("dist") if fn.endswith(".whl")
]
if wheels:
print("available wheels:")
for wheel in wheels:
print(f"\t{wheel}")
else:
raise FileNotFoundError("no wheel available")
if len(wheels) == 1:
wheel = wheels[0]
print(f"installing wheel {wheel}")
session.install(wheel)
else:
print("let pip determine the appropriate wheel")
session.install("hydpy_mpr", "--find-links", "dist")
@nox.session
def pytest(session: nox.Session) -> None:
"""Execute all unit and integration tests and measure code coverage."""
_install_hydpy_mpr(session)
session.run("pytest", "--cov", "--cov-report", "term-missing")
@nox.session
def doctest(session: nox.Session) -> None:
"""Execute script `run_doctests.py`."""
_install_hydpy_mpr(session)
session.run("python", "hydpy_mpr/testing/run_doctests.py", *session.posargs)
@nox.session(python=False)
def black(session: nox.Session) -> None:
"""Use `black` to check the source formatting."""
session.run("black", "hydpy_mpr", "--check")
@nox.session(python=False)
def pylint(session: nox.Session) -> None:
"""Use `pylint` to evaluate the code style."""
session.run("pylint", "hydpy_mpr")
@nox.session(python=False)
def mypy(session: nox.Session) -> None:
"""Use "mypy" to check the correctness of all type hints and the source code's type
safety strictly."""
session.run("mypy", "hydpy_mpr")