|
43 | 43 |
|
44 | 44 | DEFAULT_PYTHON_VERSION = "3.14" |
45 | 45 |
|
46 | | -UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 46 | +UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 47 | +ALL_PYTHON = list(UNIT_TEST_PYTHON_VERSIONS) |
| 48 | +ALL_PYTHON.extend(["3.7"]) |
47 | 49 | UNIT_TEST_STANDARD_DEPENDENCIES = [ |
48 | 50 | "mock", |
49 | 51 | "asyncmock", |
|
80 | 82 | ], |
81 | 83 | } |
82 | 84 |
|
83 | | -SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.9", "3.12", "3.13", "3.14"] |
| 85 | +SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ALL_PYTHON |
84 | 86 | SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [ |
85 | 87 | "mock", |
86 | 88 | "pytest", |
@@ -137,12 +139,14 @@ def wrapper(*args, **kwargs): |
137 | 139 | "unit", |
138 | 140 | "system", |
139 | 141 | "cover", |
| 142 | + "prerelease_deps", |
| 143 | + "blacken", |
140 | 144 | "lint", |
141 | 145 | "lint_setup_py", |
142 | | - "blacken", |
| 146 | + "format", |
| 147 | + "mypy", |
143 | 148 | "docs", |
144 | 149 | "docfx", |
145 | | - "format", |
146 | 150 | ] |
147 | 151 |
|
148 | 152 | # Error if a python version is missing |
@@ -235,7 +239,7 @@ def install_unittest_dependencies(session, *constraints): |
235 | 239 | session.install("-e", ".", *constraints) |
236 | 240 |
|
237 | 241 |
|
238 | | -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) |
| 242 | +@nox.session(python=ALL_PYTHON) |
239 | 243 | @nox.parametrize( |
240 | 244 | "protobuf_implementation", |
241 | 245 | ["python", "upb", "cpp"], |
@@ -332,6 +336,9 @@ def system(session): |
332 | 336 | system_test_path = os.path.join("tests", "system.py") |
333 | 337 | system_test_folder_path = os.path.join("tests", "system") |
334 | 338 |
|
| 339 | + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): |
| 340 | + session.skip("Credentials must be set via environment variable GOOGLE_APPLICATION_CREDENTIALS") |
| 341 | + |
335 | 342 | # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. |
336 | 343 | if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": |
337 | 344 | session.skip("RUN_SYSTEM_TESTS is set to false, skipping") |
@@ -376,6 +383,9 @@ def system_noextras(session): |
376 | 383 | system_test_path = os.path.join("tests", "system.py") |
377 | 384 | system_test_folder_path = os.path.join("tests", "system") |
378 | 385 |
|
| 386 | + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): |
| 387 | + session.skip("Credentials must be set via environment variable GOOGLE_APPLICATION_CREDENTIALS") |
| 388 | + |
379 | 389 | # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. |
380 | 390 | if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": |
381 | 391 | session.skip("RUN_SYSTEM_TESTS is set to false, skipping") |
@@ -659,24 +669,48 @@ def prerelease_deps(session, protobuf_implementation): |
659 | 669 |
|
660 | 670 | # Only run system tests if found. |
661 | 671 | if os.path.exists(system_test_path): |
662 | | - session.run( |
663 | | - "py.test", |
664 | | - "--verbose", |
665 | | - f"--junitxml=system_{session.python}_sponge_log.xml", |
666 | | - system_test_path, |
667 | | - *session.posargs, |
668 | | - env={ |
669 | | - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, |
670 | | - }, |
671 | | - ) |
| 672 | + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): |
| 673 | + session.log("Skipping system tests - no credentials") |
| 674 | + else: |
| 675 | + session.run( |
| 676 | + "py.test", |
| 677 | + "--verbose", |
| 678 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 679 | + system_test_path, |
| 680 | + *session.posargs, |
| 681 | + env={ |
| 682 | + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, |
| 683 | + }, |
| 684 | + ) |
672 | 685 | if os.path.exists(system_test_folder_path): |
673 | | - session.run( |
674 | | - "py.test", |
675 | | - "--verbose", |
676 | | - f"--junitxml=system_{session.python}_sponge_log.xml", |
677 | | - system_test_folder_path, |
678 | | - *session.posargs, |
679 | | - env={ |
680 | | - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, |
681 | | - }, |
682 | | - ) |
| 686 | + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): |
| 687 | + session.log("Skipping system folder tests - no credentials") |
| 688 | + else: |
| 689 | + session.run( |
| 690 | + "py.test", |
| 691 | + "--verbose", |
| 692 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 693 | + system_test_folder_path, |
| 694 | + *session.posargs, |
| 695 | + env={ |
| 696 | + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, |
| 697 | + }, |
| 698 | + ) |
| 699 | + |
| 700 | + |
| 701 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 702 | +def mypy(session): |
| 703 | + """Run the type checker.""" |
| 704 | + # TODO(https://github.com/googleapis/google-cloud-python/issues/16014): |
| 705 | + # Add mypy tests |
| 706 | + session.skip("mypy tests are not yet supported") |
| 707 | + |
| 708 | + |
| 709 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 710 | +def core_deps_from_source(session): |
| 711 | + """Run all tests with core dependencies installed from source |
| 712 | + rather than pulling the dependencies from PyPI. |
| 713 | + """ |
| 714 | + # TODO(https://github.com/googleapis/google-cloud-python/issues/16014): |
| 715 | + # Add core deps from source tests |
| 716 | + session.skip("Core deps from source tests are not yet supported") |
0 commit comments