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