@@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints):
160
160
session .install ("-e" , "." , * constraints )
161
161
162
162
163
- def default (session ):
163
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
164
+ @nox .parametrize (
165
+ "protobuf_implementation" ,
166
+ ["python" , "upb" , "cpp" ],
167
+ )
168
+ def unit (session , protobuf_implementation ):
164
169
# Install all test dependencies, then install this package in-place.
165
170
171
+ if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
172
+ session .skip ("cpp implementation is not supported in python 3.11+" )
173
+
166
174
constraints_path = str (
167
175
CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
168
176
)
169
177
install_unittest_dependencies (session , "-c" , constraints_path )
170
178
179
+ # TODO(https://github.com/googleapis/synthtool/issues/1976):
180
+ # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
181
+ # The 'cpp' implementation requires Protobuf<4.
182
+ if protobuf_implementation == "cpp" :
183
+ session .install ("protobuf<4" )
184
+
171
185
# Run py.test against the unit tests.
172
186
session .run (
173
187
"py.test" ,
@@ -181,15 +195,12 @@ def default(session):
181
195
"--cov-fail-under=0" ,
182
196
os .path .join ("tests" , "unit" ),
183
197
* session .posargs ,
198
+ env = {
199
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
200
+ },
184
201
)
185
202
186
203
187
- @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
188
- def unit (session ):
189
- """Run the unit test suite."""
190
- default (session )
191
-
192
-
193
204
def install_systemtest_dependencies (session , * constraints ):
194
205
# Use pre-release gRPC for system tests.
195
206
# Exclude version 1.52.0rc1 which has a known issue.
@@ -358,9 +369,16 @@ def docfx(session):
358
369
359
370
360
371
@nox .session (python = "3.12" )
361
- def prerelease_deps (session ):
372
+ @nox .parametrize (
373
+ "protobuf_implementation" ,
374
+ ["python" , "upb" , "cpp" ],
375
+ )
376
+ def prerelease_deps (session , protobuf_implementation ):
362
377
"""Run all tests with prerelease versions of dependencies installed."""
363
378
379
+ if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
380
+ session .skip ("cpp implementation is not supported in python 3.11+" )
381
+
364
382
# Install all dependencies
365
383
session .install ("-e" , ".[all, tests, tracing]" )
366
384
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -397,9 +415,9 @@ def prerelease_deps(session):
397
415
"protobuf" ,
398
416
# dependency of grpc
399
417
"six" ,
418
+ "grpc-google-iam-v1" ,
400
419
"googleapis-common-protos" ,
401
- # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
402
- "grpcio!=1.52.0rc1" ,
420
+ "grpcio" ,
403
421
"grpcio-status" ,
404
422
"google-api-core" ,
405
423
"google-auth" ,
@@ -425,4 +443,10 @@ def prerelease_deps(session):
425
443
session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
426
444
session .run ("python" , "-c" , "import google.auth; print(google.auth.__version__)" )
427
445
428
- session .run ("py.test" , "tests/unit" )
446
+ session .run (
447
+ "py.test" ,
448
+ "tests/unit" ,
449
+ env = {
450
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
451
+ },
452
+ )
0 commit comments