@@ -323,3 +323,67 @@ def docfx(session):
323
323
os .path .join ("docs" , "" ),
324
324
os .path .join ("docs" , "_build" , "html" , "" ),
325
325
)
326
+
327
+
328
+ @nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
329
+ def prerelease_deps (session ):
330
+ """Run all tests with prerelease versions of dependencies installed."""
331
+
332
+ prerel_deps = [
333
+ "protobuf" ,
334
+ "googleapis-common-protos" ,
335
+ "google-auth" ,
336
+ "grpcio" ,
337
+ "grpcio-status" ,
338
+ "google-api-core" ,
339
+ "proto-plus" ,
340
+ # dependencies of google-auth
341
+ "cryptography" ,
342
+ "pyasn1" ,
343
+ ]
344
+
345
+ for dep in prerel_deps :
346
+ session .install ("--pre" , "--no-deps" , "--upgrade" , dep )
347
+
348
+ # Remaining dependencies
349
+ other_deps = ["requests" ]
350
+ session .install (* other_deps )
351
+
352
+ session .install (* UNIT_TEST_STANDARD_DEPENDENCIES )
353
+ session .install (* SYSTEM_TEST_STANDARD_DEPENDENCIES )
354
+
355
+ # Because we test minimum dependency versions on the minimum Python
356
+ # version, the first version we test with in the unit tests sessions has a
357
+ # constraints file containing all dependencies and extras.
358
+ with open (
359
+ CURRENT_DIRECTORY
360
+ / "testing"
361
+ / f"constraints-{ UNIT_TEST_PYTHON_VERSIONS [0 ]} .txt" ,
362
+ encoding = "utf-8" ,
363
+ ) as constraints_file :
364
+ constraints_text = constraints_file .read ()
365
+
366
+ # Ignore leading whitespace and comment lines.
367
+ deps = [
368
+ match .group (1 )
369
+ for match in re .finditer (
370
+ r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
371
+ )
372
+ ]
373
+
374
+ # Don't overwrite prerelease packages.
375
+ deps = [dep for dep in deps if dep not in prerel_deps ]
376
+ # We use --no-deps to ensure that pre-release versions aren't overwritten
377
+ # by the version ranges in setup.py.
378
+ session .install (* deps )
379
+ session .install ("--no-deps" , "-e" , ".[all]" )
380
+
381
+ # Print out prerelease package versions
382
+ session .run (
383
+ "python" , "-c" , "import google.protobuf; print(google.protobuf.__version__)"
384
+ )
385
+ session .run ("python" , "-c" , "import grpc; print(grpc.__version__)" )
386
+
387
+ session .run ("py.test" , "tests/unit" )
388
+ session .run ("py.test" , "tests/system" )
389
+ session .run ("py.test" , "samples/snippets" )
0 commit comments