|
19 | 19 |
|
20 | 20 | import os
|
21 | 21 | import pathlib
|
| 22 | +import re |
22 | 23 | import shutil
|
23 | 24 | import signal
|
24 | 25 | import subprocess
|
@@ -74,6 +75,83 @@ def default(session):
|
74 | 75 | )
|
75 | 76 |
|
76 | 77 |
|
| 78 | +@nox.session(python="3.12") |
| 79 | +@nox.parametrize( |
| 80 | + "protobuf_implementation", |
| 81 | + ["python", "upb", "cpp"], |
| 82 | +) |
| 83 | +def prerelease_deps(session, protobuf_implementation): |
| 84 | + """Run all tests with prerelease versions of dependencies installed.""" |
| 85 | + |
| 86 | + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): |
| 87 | + session.skip("cpp implementation is not supported in python 3.11+") |
| 88 | + |
| 89 | + # Install all dependencies |
| 90 | + session.install("-e", ".[all, tests, tracing]") |
| 91 | + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES |
| 92 | + session.install(*unit_deps_all) |
| 93 | + |
| 94 | + # Because we test minimum dependency versions on the minimum Python |
| 95 | + # version, the first version we test with in the unit tests sessions has a |
| 96 | + # constraints file containing all dependencies and extras. |
| 97 | + with open( |
| 98 | + CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_INTERPRETERS[0]}.txt", |
| 99 | + encoding="utf-8", |
| 100 | + ) as constraints_file: |
| 101 | + constraints_text = constraints_file.read() |
| 102 | + |
| 103 | + # Ignore leading whitespace and comment lines. |
| 104 | + constraints_deps = [ |
| 105 | + match.group(1) |
| 106 | + for match in re.finditer( |
| 107 | + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE |
| 108 | + ) |
| 109 | + ] |
| 110 | + |
| 111 | + session.install(*constraints_deps) |
| 112 | + |
| 113 | + prerel_deps = [ |
| 114 | + "protobuf", |
| 115 | + # dependency of grpc |
| 116 | + "six", |
| 117 | + "grpc-google-iam-v1", |
| 118 | + "google-cloud-datastore", |
| 119 | + "googleapis-common-protos", |
| 120 | + "grpcio", |
| 121 | + "grpcio-status", |
| 122 | + "google-api-core", |
| 123 | + "google-auth", |
| 124 | + "proto-plus", |
| 125 | + "google-cloud-testutils", |
| 126 | + # dependencies of google-cloud-testutils" |
| 127 | + "click", |
| 128 | + ] |
| 129 | + |
| 130 | + for dep in prerel_deps: |
| 131 | + session.install("--pre", "--no-deps", "--upgrade", dep) |
| 132 | + |
| 133 | + # Remaining dependencies |
| 134 | + other_deps = [ |
| 135 | + "requests", |
| 136 | + ] |
| 137 | + session.install(*other_deps) |
| 138 | + |
| 139 | + # Print out prerelease package versions |
| 140 | + session.run( |
| 141 | + "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" |
| 142 | + ) |
| 143 | + session.run("python", "-c", "import grpc; print(grpc.__version__)") |
| 144 | + session.run("python", "-c", "import google.auth; print(google.auth.__version__)") |
| 145 | + |
| 146 | + session.run( |
| 147 | + "py.test", |
| 148 | + "tests/unit", |
| 149 | + env={ |
| 150 | + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, |
| 151 | + }, |
| 152 | + ) |
| 153 | + |
| 154 | + |
77 | 155 | @nox.session(python=ALL_INTERPRETERS)
|
78 | 156 | def unit(session):
|
79 | 157 | """Run the unit test suite."""
|
|
0 commit comments