1
1
# -*- coding: utf-8 -*-
2
2
#
3
- # Copyright 2024 Google LLC
3
+ # Copyright 2023 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.
@@ -162,28 +162,14 @@ def install_unittest_dependencies(session, *constraints):
162
162
session .install ("-e" , "." , * constraints )
163
163
164
164
165
- @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
166
- @nox .parametrize (
167
- "protobuf_implementation" ,
168
- ["python" , "upb" , "cpp" ],
169
- )
170
- def unit (session , protobuf_implementation ):
165
+ def default (session , tests_path ):
171
166
# Install all test dependencies, then install this package in-place.
172
167
173
- if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
174
- session .skip ("cpp implementation is not supported in python 3.11+" )
175
-
176
168
constraints_path = str (
177
169
CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
178
170
)
179
171
install_unittest_dependencies (session , "-c" , constraints_path )
180
172
181
- # TODO(https://github.com/googleapis/synthtool/issues/1976):
182
- # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
183
- # The 'cpp' implementation requires Protobuf<4.
184
- if protobuf_implementation == "cpp" :
185
- session .install ("protobuf<4" )
186
-
187
173
# Run py.test against the unit tests.
188
174
session .run (
189
175
"py.test" ,
@@ -197,12 +183,112 @@ def unit(session, protobuf_implementation):
197
183
"--cov-fail-under=0" ,
198
184
tests_path ,
199
185
* session .posargs ,
200
- env = {
201
- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
202
- },
203
186
)
204
187
205
188
189
+ def prerelease (session , tests_path ):
190
+ constraints_path = str (
191
+ CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
192
+ )
193
+
194
+ # PyArrow prerelease packages are published to an alternative PyPI host.
195
+ # https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
196
+ session .install (
197
+ "--extra-index-url" ,
198
+ "https://pypi.fury.io/arrow-nightlies/" ,
199
+ "--prefer-binary" ,
200
+ "--pre" ,
201
+ "--upgrade" ,
202
+ "pyarrow" ,
203
+ )
204
+ # Avoid pandas==2.2.0rc0 as this version causes PyArrow to fail. Once newer
205
+ # prerelease comes out, this constraint can be removed. See
206
+ # https://github.com/googleapis/python-db-dtypes-pandas/issues/234
207
+ session .install (
208
+ "--extra-index-url" ,
209
+ "https://pypi.anaconda.org/scipy-wheels-nightly/simple" ,
210
+ "--prefer-binary" ,
211
+ "--pre" ,
212
+ "--upgrade" ,
213
+ "pandas!=2.2.0rc0" ,
214
+ )
215
+ session .install (
216
+ "mock" ,
217
+ "asyncmock" ,
218
+ "pytest" ,
219
+ "pytest-cov" ,
220
+ "pytest-asyncio" ,
221
+ "-c" ,
222
+ constraints_path ,
223
+ )
224
+
225
+ # Because we test minimum dependency versions on the minimum Python
226
+ # version, the first version we test with in the unit tests sessions has a
227
+ # constraints file containing all dependencies and extras.
228
+ with open (
229
+ CURRENT_DIRECTORY
230
+ / "testing"
231
+ / f"constraints-{ UNIT_TEST_PYTHON_VERSIONS [0 ]} .txt" ,
232
+ encoding = "utf-8" ,
233
+ ) as constraints_file :
234
+ constraints_text = constraints_file .read ()
235
+
236
+ # Ignore leading whitespace and comment lines.
237
+ deps = [
238
+ match .group (1 )
239
+ for match in re .finditer (
240
+ r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
241
+ )
242
+ ]
243
+
244
+ # We use --no-deps to ensure that pre-release versions aren't overwritten
245
+ # by the version ranges in setup.py.
246
+ session .install (* deps )
247
+ session .install ("--no-deps" , "-e" , "." )
248
+
249
+ # Print out prerelease package versions.
250
+ session .run ("python" , "-m" , "pip" , "freeze" )
251
+
252
+ # Run py.test against the unit tests.
253
+ session .run (
254
+ "py.test" ,
255
+ "--quiet" ,
256
+ f"--junitxml={ os .path .split (tests_path )[- 1 ]} _prerelease_{ session .python } _sponge_log.xml" ,
257
+ "--cov=db_dtypes" ,
258
+ "--cov=tests/unit" ,
259
+ "--cov-append" ,
260
+ "--cov-config=.coveragerc" ,
261
+ "--cov-report=" ,
262
+ "--cov-fail-under=0" ,
263
+ tests_path ,
264
+ * session .posargs ,
265
+ )
266
+
267
+
268
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS [- 1 ])
269
+ def compliance (session ):
270
+ """Run the compliance test suite."""
271
+ default (session , os .path .join ("tests" , "compliance" ))
272
+
273
+
274
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS [- 1 ])
275
+ def compliance_prerelease (session ):
276
+ """Run the compliance test suite with prerelease dependencies."""
277
+ prerelease (session , os .path .join ("tests" , "compliance" ))
278
+
279
+
280
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS )
281
+ def unit (session ):
282
+ """Run the unit test suite."""
283
+ default (session , os .path .join ("tests" , "unit" ))
284
+
285
+
286
+ @nox .session (python = UNIT_TEST_PYTHON_VERSIONS [- 1 ])
287
+ def unit_prerelease (session ):
288
+ """Run the unit test suite with prerelease dependencies."""
289
+ prerelease (session , os .path .join ("tests" , "unit" ))
290
+
291
+
206
292
def install_systemtest_dependencies (session , * constraints ):
207
293
# Use pre-release gRPC for system tests.
208
294
# Exclude version 1.52.0rc1 which has a known issue.
@@ -371,16 +457,9 @@ def docfx(session):
371
457
372
458
373
459
@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
374
- @nox .parametrize (
375
- "protobuf_implementation" ,
376
- ["python" , "upb" , "cpp" ],
377
- )
378
- def prerelease_deps (session , protobuf_implementation ):
460
+ def prerelease_deps (session ):
379
461
"""Run all tests with prerelease versions of dependencies installed."""
380
462
381
- if protobuf_implementation == "cpp" and session .python in ("3.11" , "3.12" ):
382
- session .skip ("cpp implementation is not supported in python 3.11+" )
383
-
384
463
# Install all dependencies
385
464
session .install ("-e" , ".[all, tests, tracing]" )
386
465
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -415,9 +494,9 @@ def prerelease_deps(session, protobuf_implementation):
415
494
"protobuf" ,
416
495
# dependency of grpc
417
496
"six" ,
418
- "grpc-google-iam-v1" ,
419
497
"googleapis-common-protos" ,
420
- "grpcio" ,
498
+ # Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
499
+ "grpcio!=1.52.0rc1" ,
421
500
"grpcio-status" ,
422
501
"google-api-core" ,
423
502
"google-auth" ,
@@ -443,13 +522,7 @@ def prerelease_deps(session, protobuf_implementation):
443
522
session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
444
523
session .run ("python" , "-c" , "import google.auth; print(google.auth.__version__)" )
445
524
446
- session .run (
447
- "py.test" ,
448
- "tests/unit" ,
449
- env = {
450
- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
451
- },
452
- )
525
+ session .run ("py.test" , "tests/unit" )
453
526
454
527
system_test_path = os .path .join ("tests" , "system.py" )
455
528
system_test_folder_path = os .path .join ("tests" , "system" )
@@ -462,9 +535,6 @@ def prerelease_deps(session, protobuf_implementation):
462
535
f"--junitxml=system_{ session .python } _sponge_log.xml" ,
463
536
system_test_path ,
464
537
* session .posargs ,
465
- env = {
466
- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
467
- },
468
538
)
469
539
if os .path .exists (system_test_folder_path ):
470
540
session .run (
@@ -473,7 +543,4 @@ def prerelease_deps(session, protobuf_implementation):
473
543
f"--junitxml=system_{ session .python } _sponge_log.xml" ,
474
544
system_test_folder_path ,
475
545
* session .posargs ,
476
- env = {
477
- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
478
- },
479
546
)
0 commit comments