Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 7294f00

Browse files
committed
reuse nox unit session as per review comment
1 parent b5f1126 commit 7294f00

1 file changed

Lines changed: 24 additions & 11 deletions

File tree

noxfile.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def install_prerelease_dependencies(session, constraints_path):
100100
]
101101
session.install(*other_deps)
102102

103-
104103
def default(session, install_grpc=True, prerelease=False, install_async_rest=False):
105104
"""Default unit test session.
106105
@@ -203,18 +202,32 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
203202
session.run(*pytest_args)
204203

205204

206-
@nox.session(python=PYTHON_VERSIONS)
207-
@nox.parametrize(
208-
["install_grpc", "install_async_rest"],
209-
[
210-
(True, False), # Run unit tests with grpcio installed
211-
(False, False), # Run unit tests without grpcio installed
212-
(True, True), # Run unit tests with grpcio and async rest installed
213-
],
214-
)
215-
def unit(session, install_grpc, install_async_rest):
205+
@nox.session(python=PYTHON_VERSIONS)
206+
@nox.parametrize(
207+
["install_grpc", "install_async_rest", "python_versions", "proto4"],
208+
[
209+
(True, False, None, False), # Run unit tests with grpcio installed
210+
(False, False, None, False), # Run unit tests without grpcio installed
211+
(True, True, None, False), # Run unit tests with grpcio and async rest installed
212+
213+
# TODO: Remove once we stop support for protobuf 4.x.
214+
(True, False, ["3.9", "3.10", "3.11"], True), # Run proto4 tests with grpcio/grpcio-gcp installed
215+
],
216+
)
217+
def unit(session, install_grpc, install_async_rest, python_versions=None, proto4=False):
218+
216219
"""Run the unit test suite."""
217220

221+
# TODO: Remove this code and the corresponding parameter once we stop support for protobuf 4.x.
222+
if python_versions and session.python not in python_versions:
223+
session.log(f"Skipping session for Python {session.python}")
224+
session.skip()
225+
226+
# TODO: Remove this code and the corresponding parameter once we stop support for protobuf 4.x.
227+
if proto4:
228+
# Pin protobuf to a 4.x version to ensure coverage for the legacy code path.
229+
session.install("protobuf>=4.25.8,<5.0.0")
230+
218231
default(
219232
session=session,
220233
install_grpc=install_grpc,

0 commit comments

Comments
 (0)