-
Notifications
You must be signed in to change notification settings - Fork 5
/
noxfile.py
104 lines (87 loc) · 2.44 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Standard Library
import os
from pathlib import Path
# Third Party Library
import nox
nox.options.stop_on_first_error = True
pythons = ["3.10", "3.11", "3.12", "3.13"]
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
os.environ.pop("PYTHONPATH", None)
def venv_setup_on_create(session, install):
cwd = os.getcwd()
session.cd(session.create_tmp())
if session.run(
"python", "-Esc", "import data_extractor", success_codes=(1, 0), silent=True
):
install(session)
session.cd(cwd)
@nox.session(python=pythons, venv_backend="venv")
@nox.parametrize(
"extractor_backend",
[
None,
"jsonpath-extractor",
"jsonpath-rw",
"jsonpath-rw-ext",
"lxml",
"cssselect",
],
)
def coverage_test(session, extractor_backend):
venv_setup_on_create(
session,
lambda s: s.run(
"pdm",
"sync",
"-G",
"test",
*(("-G", extractor_backend) if extractor_backend else tuple()),
external=True,
),
)
session.run(
"pytest",
"-vv",
"--cov=data_extractor",
"--cov-append",
"--ignore",
"tests/typesafety",
*session.posargs,
)
@nox.session(python=pythons, venv_backend="venv")
def coverage_report(session):
venv_setup_on_create(
session,
lambda s: s.run("pdm", "sync", "-G", "test", external=True),
)
session.run("coverage", "report")
session.run("coverage", "xml")
session.run("coverage", "html")
session.log(
f">> open file:/{(Path() / 'htmlcov/index.html').absolute()} to see coverage"
)
@nox.session(python=pythons, venv_backend="venv")
def test_mypy_plugin(session):
venv_setup_on_create(
session,
lambda s: s.run("pdm", "sync", "-G", "test-mypy-plugin", external=True),
)
session.run(
"pytest",
"-vv",
"--cov=data_extractor/contrib/mypy",
"--cov-append",
"--mypy-same-process",
"--mypy-ini-file=./tests/mypy.ini",
"tests/typesafety",
*(session.posargs if session.posargs else tuple()),
)
@nox.session(python=pythons[-1:], venv_backend="venv")
def build_readme(session):
venv_setup_on_create(
session,
lambda s: s.run("pdm", "sync", "-G", "build_readme", external=True),
)
session.run(
"python", "scripts/build_readme.py", "README.template.rst", "README.rst"
)