forked from strawberry-graphql/strawberry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
167 lines (130 loc) · 4.42 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import nox
from nox_poetry import Session, session
nox.options.reuse_existing_virtualenvs = True
nox.options.error_on_external_run = True
PYTHON_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
COMMON_PYTEST_OPTIONS = [
"--cov=.",
"--cov-append",
"--cov-report=xml",
"-n",
"auto",
"--showlocals",
"-vv",
"--ignore=tests/typecheckers",
"--ignore=tests/cli",
"--ignore=tests/benchmarks",
"--ignore=tests/experimental/pydantic",
]
INTEGRATIONS = [
"asgi",
"aiohttp",
"chalice",
"channels",
"django",
"fastapi",
"flask",
"quart",
"sanic",
"starlite",
"litestar",
"pydantic",
]
@session(python=PYTHON_VERSIONS, name="Tests", tags=["tests"])
def tests(session: Session) -> None:
session.run_always("poetry", "install", external=True)
markers = (
["-m", f"not {integration}", f"--ignore=tests/{integration}"]
for integration in INTEGRATIONS
)
markers = [item for sublist in markers for item in sublist]
session.run(
"pytest",
*COMMON_PYTEST_OPTIONS,
*markers,
)
@session(python=["3.11", "3.12"], name="Django tests", tags=["tests"])
@nox.parametrize("django", ["4.2.0", "4.1.0", "4.0.0", "3.2.0"])
def tests_django(session: Session, django: str) -> None:
session.run_always("poetry", "install", external=True)
session._session.install(f"django~={django}") # type: ignore
session._session.install("pytest-django") # type: ignore
session.run("pytest", *COMMON_PYTEST_OPTIONS, "-m", "django")
@session(python=["3.11"], name="Starlette tests", tags=["tests"])
@nox.parametrize("starlette", ["0.28.0", "0.27.0", "0.26.1"])
def tests_starlette(session: Session, starlette: str) -> None:
session.run_always("poetry", "install", external=True)
session._session.install(f"starlette=={starlette}") # type: ignore
session.run("pytest", *COMMON_PYTEST_OPTIONS, "-m", "asgi")
@session(python=["3.11"], name="Test integrations", tags=["tests"])
@nox.parametrize(
"integration",
[
"aiohttp",
"chalice",
"channels",
"fastapi",
"flask",
"quart",
"sanic",
"starlite",
"litestar",
],
)
def tests_integrations(session: Session, integration: str) -> None:
session.run_always("poetry", "install", external=True)
session._session.install(integration) # type: ignore
if integration == "aiohttp":
session._session.install("pytest-aiohttp") # type: ignore
elif integration == "channels":
session._session.install("pytest-django") # type: ignore
session._session.install("daphne") # type: ignore
elif integration == "starlite":
session._session.install("pydantic<2.0") # type: ignore
session.run("pytest", *COMMON_PYTEST_OPTIONS, "-m", integration)
@session(python=PYTHON_VERSIONS, name="Pydantic tests", tags=["tests", "pydantic"])
@nox.parametrize("pydantic", ["1.10", "2.7.0"])
def test_pydantic(session: Session, pydantic: str) -> None:
session.run_always("poetry", "install", external=True)
session._session.install(f"pydantic~={pydantic}") # type: ignore
session.run(
"pytest",
"--cov=.",
"--cov-append",
"--cov-report=xml",
"-m",
"pydantic",
"--ignore=tests/cli",
)
@session(python=PYTHON_VERSIONS, name="Type checkers tests", tags=["tests"])
def tests_typecheckers(session: Session) -> None:
session.run_always("poetry", "install", external=True)
session.install("pyright")
session.install("pydantic")
session.install("git+https://github.com/python/mypy.git#master")
session.run(
"pytest",
"--cov=.",
"--cov-append",
"--cov-report=xml",
"tests/typecheckers",
"-vv",
)
@session(python=PYTHON_VERSIONS, name="CLI tests", tags=["tests"])
def tests_cli(session: Session) -> None:
session.run_always("poetry", "install", external=True)
session._session.install("uvicorn") # type: ignore
session._session.install("starlette") # type: ignore
session.run(
"pytest",
"--cov=.",
"--cov-append",
"--cov-report=xml",
"tests/cli",
"-vv",
)
@session(name="Mypy", tags=["lint"])
def mypy(session: Session) -> None:
session.run_always("poetry", "install", "--with", "integrations", external=True)
session.install("mypy")
session.run("mypy", "--config-file", "mypy.ini")