-
Notifications
You must be signed in to change notification settings - Fork 3
/
noxfile.py
71 lines (54 loc) · 1.84 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
"""Test scenarios for drf-json-schema."""
import os
import subprocess
import nox
from nox.sessions import Session
# pipenv and tox don't interact very well, they seem to be highly
# dependent on what python/python environment you run nox in.
# So instead of dealing with that, we just convert the lockfile to
# a requirements file and install like that.
def install_pipenv_requirements(session: Session) -> None:
"""Generate a requirements file from pipfile.lock and install those."""
OUTFILE = os.path.join(".nox", "reqs.txt")
session.install("pipenv")
reqs = subprocess.check_output(["pipenv", "lock", "--dev", "-r"])
with open(OUTFILE, "wb+") as f:
f.write(reqs)
session.install("-r", OUTFILE)
if os.environ.get("CI"):
# On CI, we allow it to set the Python version
nox_session = nox.session
else:
nox_session = nox.session(python=["3.6", "3.7", "3.8", "3.9"])
@nox_session
@nox.parametrize("django", ["2.2", "3.1"])
@nox.parametrize("drf", ["3.11", "3.12"])
def test(session: Session, django: str, drf: str) -> None:
"""Run unit tests."""
install_pipenv_requirements(session)
session.install(f"django=={django}")
session.install(f"djangorestframework=={drf}")
session.run(
"py.test",
"--flake8",
"--cov=rest_framework_json_schema",
"--cov-append",
"rest_framework_json_schema/",
"tests/",
env={"PYTHONPATH": "."},
)
@nox.session
def black(session: Session) -> None:
"""Check black."""
session.install("black==21.5b2")
session.run("black", "--check", ".")
@nox.session
def mypy(session: Session) -> None:
"""Check mypy."""
session.install("mypy")
session.run("mypy", ".")
@nox.session
def pydocstyle(session: Session) -> None:
"""Check docstrings."""
session.install("pydocstyle")
session.run("pydocstyle")