|
1 |
| -import os |
2 |
| -import shutil |
3 |
| - |
4 |
| -import nox |
5 |
| - |
6 |
| - |
7 |
| -def tests_impl(session, extras="socks,secure,brotli"): |
8 |
| - # Install deps and the package itself. |
9 |
| - session.install("-r", "dev-requirements.txt") |
10 |
| - session.install(".[{extras}]".format(extras=extras)) |
11 |
| - |
12 |
| - # Show the pip version. |
13 |
| - session.run("pip", "--version") |
14 |
| - # Print the Python version and bytesize. |
15 |
| - session.run("python", "--version") |
16 |
| - session.run("python", "-c", "import struct; print(struct.calcsize('P') * 8)") |
17 |
| - # Print OpenSSL information. |
18 |
| - session.run("python", "-m", "OpenSSL.debug") |
19 |
| - |
20 |
| - session.run( |
21 |
| - "pytest", |
22 |
| - "-r", |
23 |
| - "a", |
24 |
| - "--cov=urllib3", |
25 |
| - *(session.posargs or ("test/",)), |
26 |
| - env={"PYTHONWARNINGS": "always::DeprecationWarning"} |
27 |
| - ) |
28 |
| - session.run("coverage", "xml") |
29 |
| - session.run("python", "cleancov.py", "coverage.xml") |
30 |
| - |
31 |
| - |
32 |
| -@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "pypy"]) |
33 |
| -def test(session): |
34 |
| - tests_impl(session) |
35 |
| - |
36 |
| - |
37 |
| -@nox.session(python=["2", "3"]) |
38 |
| -def google_brotli(session): |
39 |
| - # https://pypi.org/project/Brotli/ is the Google version of brotli, so |
40 |
| - # install it separately and don't install our brotli extra (which installs |
41 |
| - # brotlipy). |
42 |
| - session.install("brotli") |
43 |
| - tests_impl(session, extras="socks,secure") |
44 |
| - |
45 |
| - |
46 |
| -@nox.session(python="2.7") |
47 |
| -def app_engine(session): |
48 |
| - session.install("-r", "dev-requirements.txt") |
49 |
| - session.install(".") |
50 |
| - session.run( |
51 |
| - "coverage", |
52 |
| - "run", |
53 |
| - "--parallel-mode", |
54 |
| - "-m", |
55 |
| - "pytest", |
56 |
| - "-r", |
57 |
| - "sx", |
58 |
| - "test/appengine", |
59 |
| - *session.posargs |
60 |
| - ) |
61 |
| - session.run("coverage", "combine") |
62 |
| - session.run("coverage", "report", "-m") |
63 |
| - |
64 |
| - |
65 |
| -@nox.session() |
66 |
| -def blacken(session): |
67 |
| - """Run black code formater.""" |
68 |
| - session.install("black") |
69 |
| - session.run("black", "src", "dummyserver", "test", "noxfile.py", "setup.py") |
70 |
| - |
71 |
| - lint(session) |
72 |
| - |
73 |
| - |
74 |
| -@nox.session |
75 |
| -def lint(session): |
76 |
| - session.install("flake8", "black") |
77 |
| - session.run("flake8", "--version") |
78 |
| - session.run("black", "--version") |
79 |
| - session.run( |
80 |
| - "black", "--check", "src", "dummyserver", "test", "noxfile.py", "setup.py" |
81 |
| - ) |
82 |
| - session.run("flake8", "setup.py", "docs", "dummyserver", "src", "test") |
83 |
| - |
84 |
| - |
85 |
| -@nox.session |
86 |
| -def docs(session): |
87 |
| - session.install("-r", "docs/requirements.txt") |
88 |
| - session.install(".[socks,secure,brotli]") |
89 |
| - |
90 |
| - session.chdir("docs") |
91 |
| - if os.path.exists("_build"): |
92 |
| - shutil.rmtree("_build") |
93 |
| - session.run("sphinx-build", "-W", ".", "_build/html") |
| 1 | +import os |
| 2 | +import shutil |
| 3 | + |
| 4 | +import nox |
| 5 | + |
| 6 | + |
| 7 | +def tests_impl(session, extras="socks,secure,brotli"): |
| 8 | + # Install deps and the package itself. |
| 9 | + session.install("-r", "dev-requirements.txt") |
| 10 | + session.install(".[{extras}]".format(extras=extras)) |
| 11 | + |
| 12 | + # Show the pip version. |
| 13 | + session.run("pip", "--version") |
| 14 | + # Print the Python version and bytesize. |
| 15 | + session.run("python", "--version") |
| 16 | + session.run("python", "-c", "import struct; print(struct.calcsize('P') * 8)") |
| 17 | + # Print OpenSSL information. |
| 18 | + session.run("python", "-m", "OpenSSL.debug") |
| 19 | + |
| 20 | + session.run( |
| 21 | + "pytest", |
| 22 | + "-r", |
| 23 | + "a", |
| 24 | + "--tb=native", |
| 25 | + "--cov=urllib3", |
| 26 | + "--no-success-flaky-report", |
| 27 | + *(session.posargs or ("test/",)), |
| 28 | + env={"PYTHONWARNINGS": "always::DeprecationWarning"} |
| 29 | + ) |
| 30 | + session.run("coverage", "xml") |
| 31 | + session.run("python", "cleancov.py", "coverage.xml") |
| 32 | + |
| 33 | + |
| 34 | +@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "pypy"]) |
| 35 | +def test(session): |
| 36 | + tests_impl(session) |
| 37 | + |
| 38 | + |
| 39 | +@nox.session(python=["2", "3"]) |
| 40 | +def google_brotli(session): |
| 41 | + # https://pypi.org/project/Brotli/ is the Google version of brotli, so |
| 42 | + # install it separately and don't install our brotli extra (which installs |
| 43 | + # brotlipy). |
| 44 | + session.install("brotli") |
| 45 | + tests_impl(session, extras="socks,secure") |
| 46 | + |
| 47 | + |
| 48 | +@nox.session(python="2.7") |
| 49 | +def app_engine(session): |
| 50 | + session.install("-r", "dev-requirements.txt") |
| 51 | + session.install(".") |
| 52 | + session.run( |
| 53 | + "coverage", |
| 54 | + "run", |
| 55 | + "--parallel-mode", |
| 56 | + "-m", |
| 57 | + "pytest", |
| 58 | + "-r", |
| 59 | + "sx", |
| 60 | + "test/appengine", |
| 61 | + *session.posargs |
| 62 | + ) |
| 63 | + session.run("coverage", "combine") |
| 64 | + session.run("coverage", "report", "-m") |
| 65 | + |
| 66 | + |
| 67 | +@nox.session() |
| 68 | +def blacken(session): |
| 69 | + """Run black code formater.""" |
| 70 | + session.install("black") |
| 71 | + session.run("black", "src", "dummyserver", "test", "noxfile.py", "setup.py") |
| 72 | + |
| 73 | + lint(session) |
| 74 | + |
| 75 | + |
| 76 | +@nox.session |
| 77 | +def lint(session): |
| 78 | + session.install("flake8", "black") |
| 79 | + session.run("flake8", "--version") |
| 80 | + session.run("black", "--version") |
| 81 | + session.run( |
| 82 | + "black", "--check", "src", "dummyserver", "test", "noxfile.py", "setup.py" |
| 83 | + ) |
| 84 | + session.run("flake8", "setup.py", "docs", "dummyserver", "src", "test") |
| 85 | + |
| 86 | + |
| 87 | +@nox.session |
| 88 | +def docs(session): |
| 89 | + session.install("-r", "docs/requirements.txt") |
| 90 | + session.install(".[socks,secure,brotli]") |
| 91 | + |
| 92 | + session.chdir("docs") |
| 93 | + if os.path.exists("_build"): |
| 94 | + shutil.rmtree("_build") |
| 95 | + session.run("sphinx-build", "-W", ".", "_build/html") |
0 commit comments