Skip to content

Commit d7c0b2b

Browse files
chalmerloweparthea
authored andcommitted
chore: refine prerelease_deps to conditionally run system tests
1 parent c02544d commit d7c0b2b

1 file changed

Lines changed: 32 additions & 40 deletions

File tree

packages/google-cloud-spanner/noxfile.py

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
DEFAULT_PYTHON_VERSION = "3.14"
4040

4141
DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"
42-
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.14"]
42+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.12"]
4343

4444
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
4545
"3.8",
@@ -566,14 +566,6 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
566566
):
567567
session.skip("cpp implementation is not supported in python 3.11+")
568568

569-
# Sanity check: Only run tests if credentials or emulator are set.
570-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", "") and not os.environ.get(
571-
"SPANNER_EMULATOR_HOST", ""
572-
):
573-
session.skip(
574-
"Credentials or emulator host must be set via environment variable"
575-
)
576-
577569
# Install all dependencies
578570
session.install("-e", ".[all, tests, tracing]")
579571
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -656,37 +648,37 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
656648

657649
# Only run system tests for one protobuf implementation on real Spanner to speed up the build.
658650
if os.environ.get("SPANNER_EMULATOR_HOST") or protobuf_implementation == "python":
659-
# Only run system tests if found.
660-
if os.path.exists(system_test_path):
661-
session.run(
662-
"py.test",
663-
"--verbose",
664-
"-o",
665-
"asyncio_mode=auto",
666-
f"--junitxml=system_{session.python}_sponge_log.xml",
667-
system_test_path,
668-
*session.posargs,
669-
env={
670-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
671-
"SPANNER_DATABASE_DIALECT": database_dialect,
672-
"SKIP_BACKUP_TESTS": "true",
673-
},
674-
)
675-
elif os.path.exists(system_test_folder_path):
676-
session.run(
677-
"py.test",
678-
"--verbose",
679-
"-o",
680-
"asyncio_mode=auto",
681-
f"--junitxml=system_{session.python}_sponge_log.xml",
682-
system_test_folder_path,
683-
*session.posargs,
684-
env={
685-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
686-
"SPANNER_DATABASE_DIALECT": database_dialect,
687-
"SKIP_BACKUP_TESTS": "true",
688-
},
689-
)
651+
# Sanity check: Only run system tests if credentials or emulator are set.
652+
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") or os.environ.get("SPANNER_EMULATOR_HOST"):
653+
# Only run system tests if found.
654+
if os.path.exists(system_test_path):
655+
session.run(
656+
"py.test",
657+
"--verbose",
658+
f"--junitxml=system_{session.python}_sponge_log.xml",
659+
system_test_path,
660+
*session.posargs,
661+
env={
662+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
663+
"SPANNER_DATABASE_DIALECT": database_dialect,
664+
"SKIP_BACKUP_TESTS": "true",
665+
},
666+
)
667+
elif os.path.exists(system_test_folder_path):
668+
session.run(
669+
"py.test",
670+
"--verbose",
671+
f"--junitxml=system_{session.python}_sponge_log.xml",
672+
system_test_folder_path,
673+
*session.posargs,
674+
env={
675+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
676+
"SPANNER_DATABASE_DIALECT": database_dialect,
677+
"SKIP_BACKUP_TESTS": "true",
678+
},
679+
)
680+
else:
681+
session.log("Skipping system tests because credentials/emulator are missing")
690682

691683
@nox.session(python=DEFAULT_PYTHON_VERSION)
692684
def mypy(session):

0 commit comments

Comments
 (0)