forked from psf/requests
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
noxfile.py
79 lines (63 loc) · 1.96 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
from __future__ import annotations
import os
import shutil
import nox
def tests_impl(
session: nox.Session,
extras: str = "socks,ws",
cohabitation: bool | None = False,
) -> None:
# Install deps and the package itself.
session.install("-r", "requirements-dev.txt")
session.install(f".[{extras}]", silent=False)
# Show the pip version.
session.run("pip", "--version")
session.run("python", "--version")
if cohabitation is True:
session.run("pip", "install", "urllib3")
session.run("python", "-m", "niquests.help")
elif cohabitation is None:
session.run("pip", "install", "urllib3")
session.run("pip", "uninstall", "-y", "urllib3")
session.run("python", "-m", "niquests.help")
session.run(
"python",
"-m",
"coverage",
"run",
"--parallel-mode",
"-m",
"pytest",
"-v",
"-ra",
f"--color={'yes' if 'GITHUB_ACTIONS' in os.environ else 'auto'}",
"--tb=native",
"--durations=10",
"--strict-config",
"--strict-markers",
*(session.posargs or ("tests/",)),
env={"PYTHONWARNINGS": "always::DeprecationWarning"},
)
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy"])
def test(session: nox.Session) -> None:
tests_impl(session)
@nox.session(
python=[
"3.11",
]
)
def test_cohabitation(session: nox.Session) -> None:
tests_impl(session, cohabitation=True)
tests_impl(session, cohabitation=None)
@nox.session
def lint(session: nox.Session) -> None:
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
@nox.session
def docs(session: nox.Session) -> None:
session.install("-r", "docs/requirements.txt")
session.install(".[socks]")
session.chdir("docs")
if os.path.exists("_build"):
shutil.rmtree("_build")
session.run("sphinx-build", "-b", "html", ".", "_build/html")