-
Notifications
You must be signed in to change notification settings - Fork 2
/
noxfile.py
50 lines (37 loc) · 1.41 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
import nox
nox.options.stop_on_first_error = True
nox.options.reuse_existing_virtualenvs = True
nox.options.keywords = "test + check"
source_files = ("kapten", "tests", "setup.py", "noxfile.py")
lint_requirements = ("flake8", "black", "isort")
@nox.session(python=["3.6", "3.7", "3.8"])
def test(session):
session.install(
"--upgrade",
"pytest",
"pytest-asyncio",
"pytest-cov",
"asynctest",
"respx==0.8.1",
"requests", # needed by starlette test client
)
session.install("-e", ".[server]")
options = session.posargs
if "-k" in options:
options.append("--no-cov")
session.run("pytest", "-v", *options)
@nox.session
def check(session):
session.install("--upgrade", "flake8-bugbear", "mypy", *lint_requirements)
session.install("-e", ".[server]")
session.run("black", "--check", "--diff", "--target-version=py36", *source_files)
session.run("isort", "--check", "--diff", "--project=kapten", "-rc", *source_files)
session.run("flake8", *source_files)
session.run("mypy", "kapten")
@nox.session
def lint(session):
session.install("--upgrade", "autoflake", *lint_requirements)
session.run("autoflake", "--in-place", "--recursive", *source_files)
session.run("isort", "--project=kapten", "--recursive", "--apply", *source_files)
session.run("black", "--target-version=py36", *source_files)
check(session)