1
1
# -*- coding: utf-8 -*-
2
2
#
3
- # Copyright 2023 Google LLC
3
+ # Copyright 2024 Google LLC
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
@@ -185,14 +185,28 @@ def install_unittest_dependencies(session, *constraints):
185
185
session .install ("-e" , "." , * constraints )
186
186
187
187
188
- def default (session ):
188
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
189
+ @nox .parametrize (
190
+ "protobuf_implementation" ,
191
+ ["python" , "upb" , "cpp" ],
192
+ )
193
+ def unit (session , protobuf_implementation ):
189
194
# Install all test dependencies, then install this package in-place.
190
195
196
+ if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
197
+ session .skip ("cpp implementation is not supported in python 3.11+" )
198
+
191
199
constraints_path = str (
192
200
CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
193
201
)
194
202
install_unittest_dependencies (session , "-c" , constraints_path )
195
203
204
+ # TODO(https://github.com/googleapis/synthtool/issues/1976):
205
+ # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
206
+ # The 'cpp' implementation requires Protobuf<4.
207
+ if protobuf_implementation == "cpp" :
208
+ session .install ("protobuf<4" )
209
+
196
210
# Run py.test against the unit tests.
197
211
session .run (
198
212
"py.test" ,
@@ -206,15 +220,12 @@ def default(session):
206
220
"--cov-fail-under=0" ,
207
221
os .path .join ("tests" , "unit" ),
208
222
* session .posargs ,
223
+ env = {
224
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
225
+ },
209
226
)
210
227
211
228
212
- @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
213
- def unit (session ):
214
- """Run the unit test suite."""
215
- default (session )
216
-
217
-
218
229
def install_systemtest_dependencies (session , * constraints ):
219
230
# Use pre-release gRPC for system tests.
220
231
# Exclude version 1.52.0rc1 which has a known issue.
@@ -430,10 +441,17 @@ def docfx(session):
430
441
session .run ("python" , "docs/scripts/patch_devsite_toc.py" )
431
442
432
443
433
- @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
434
- def prerelease_deps (session ):
444
+ @nox .session (python = "3.12" )
445
+ @nox .parametrize (
446
+ "protobuf_implementation" ,
447
+ ["python" , "upb" , "cpp" ],
448
+ )
449
+ def prerelease_deps (session , protobuf_implementation ):
435
450
"""Run all tests with prerelease versions of dependencies installed."""
436
451
452
+ if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
453
+ session .skip ("cpp implementation is not supported in python 3.11+" )
454
+
437
455
# Install all dependencies
438
456
session .install ("-e" , ".[all, tests, tracing]" )
439
457
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -468,9 +486,9 @@ def prerelease_deps(session):
468
486
"protobuf" ,
469
487
# dependency of grpc
470
488
"six" ,
489
+ "grpc-google-iam-v1" ,
471
490
"googleapis-common-protos" ,
472
- # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
473
- "grpcio!=1.52.0rc1" ,
491
+ "grpcio" ,
474
492
"grpcio-status" ,
475
493
"google-api-core" ,
476
494
"google-auth" ,
@@ -496,7 +514,13 @@ def prerelease_deps(session):
496
514
session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
497
515
session .run ("python" , "-c" , "import google.auth; print(google.auth.__version__)" )
498
516
499
- session .run ("py.test" , "tests/unit" )
517
+ session .run (
518
+ "py.test" ,
519
+ "tests/unit" ,
520
+ env = {
521
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
522
+ },
523
+ )
500
524
501
525
system_test_path = os .path .join ("tests" , "system.py" )
502
526
system_test_folder_path = os .path .join ("tests" , "system" )
@@ -509,6 +533,9 @@ def prerelease_deps(session):
509
533
f"--junitxml=system_{ session .python } _sponge_log.xml" ,
510
534
system_test_path ,
511
535
* session .posargs ,
536
+ env = {
537
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
538
+ },
512
539
)
513
540
if os .path .exists (system_test_folder_path ):
514
541
session .run (
@@ -517,4 +544,7 @@ def prerelease_deps(session):
517
544
f"--junitxml=system_{ session .python } _sponge_log.xml" ,
518
545
system_test_folder_path ,
519
546
* session .posargs ,
547
+ env = {
548
+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
549
+ },
520
550
)
0 commit comments