forked from P403n1x87/pytest-austin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
69 lines (47 loc) · 1.53 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
import os
import tempfile
import nox
nox.options.sessions = ["lint", "tests"]
# ---- Configuration ----
SUPPORTED_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
PYTEST_OPTIONS = [
"-vvvs",
"--cov=pytest_austin",
"--cov-report",
"term-missing",
"--steal-mojo",
]
LINT_LOCATIONS = ["pytest_austin", "test", "noxfile.py"]
LINT_EXCLUDES = []
MYPY_LOCATIONS = LINT_LOCATIONS[:1]
# ---- Helpers ----
def install_with_constraints(session, *args, **kwargs):
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
f"--output={requirements.name}",
external=True,
)
session.install(f"--constraint={requirements.name}", *args, **kwargs)
# ---- Sessions ----
@nox.session(python=SUPPORTED_PYTHON_VERSIONS)
def tests(session):
session.run("poetry", "install", "-vv", external=True)
session.run(
"poetry", "run", "python", "-m", "pytest", *PYTEST_OPTIONS,
)
@nox.session(python=SUPPORTED_PYTHON_VERSIONS)
def lint(session):
session.install(
"flake8", "flake8-bugbear", "flake8-docstrings", "flake8-import-order",
)
session.run("flake8", *LINT_LOCATIONS) # , "--exclude", *LINT_EXCLUDES)
@nox.session(python="3.7")
def coverage(session):
"""Upload coverage data."""
install_with_constraints(session, "coverage[toml]", "codecov")
session.run("coverage", "xml", "--fail-under=0")
session.run("codecov", *session.posargs)