-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
71 lines (54 loc) · 1.54 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
70
71
"""Build and test configuration file. """
import os
import nox
NOX_DIR = os.path.abspath(os.path.dirname(__file__))
DEFAULT_INTERPRETER = "3.8"
ALL_INTERPRETERS = ("3.7", "3.8", "3.9")
def get_path(*names):
return os.path.join(NOX_DIR, *names)
@nox.session(py=ALL_INTERPRETERS)
def unit(session):
# Install all dependencies.
session.install("-e", ".[testing]")
# Run py.test against the unit tests.
run_args = ["pytest"]
if session.posargs:
run_args.extend(session.posargs)
else:
run_args.extend(
[
"--cov=droplets",
"--cov=tests",
"--cov-report=term-missing",
]
)
run_args.append(get_path("tests"))
session.run(*run_args)
def run_black(session, use_check=False):
args = ["black"]
if use_check:
args.append("--check")
args.extend(
[
get_path("noxfile.py"),
get_path("setup.py"),
get_path("droplets"),
get_path("tests"),
]
)
session.run(*args)
@nox.session(py=DEFAULT_INTERPRETER)
def lint(session):
"""Run linters.
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", "black")
run_black(session, use_check=True)
session.run("flake8", "droplets", "tests", "setup.py")
@nox.session(py=DEFAULT_INTERPRETER)
def blacken(session):
# Install all dependencies.
session.install("black")
# Run ``black``.
run_black(session)