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