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