Skip to content

Commit 3cda3a8

Browse files
committed
chore: refine prerelease_deps to conditionally run system tests
1 parent 6b88da7 commit 3cda3a8

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

packages/google-cloud-spanner/noxfile.py

Lines changed: 32 additions & 36 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",
@@ -519,14 +519,6 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
519519
):
520520
session.skip("cpp implementation is not supported in python 3.11+")
521521

522-
# Sanity check: Only run tests if credentials or emulator are set.
523-
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", "") and not os.environ.get(
524-
"SPANNER_EMULATOR_HOST", ""
525-
):
526-
session.skip(
527-
"Credentials or emulator host must be set via environment variable"
528-
)
529-
530522
# Install all dependencies
531523
session.install("-e", ".[all, tests, tracing]")
532524
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
@@ -609,33 +601,37 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
609601

610602
# Only run system tests for one protobuf implementation on real Spanner to speed up the build.
611603
if os.environ.get("SPANNER_EMULATOR_HOST") or protobuf_implementation == "python":
612-
# Only run system tests if found.
613-
if os.path.exists(system_test_path):
614-
session.run(
615-
"py.test",
616-
"--verbose",
617-
f"--junitxml=system_{session.python}_sponge_log.xml",
618-
system_test_path,
619-
*session.posargs,
620-
env={
621-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
622-
"SPANNER_DATABASE_DIALECT": database_dialect,
623-
"SKIP_BACKUP_TESTS": "true",
624-
},
625-
)
626-
elif os.path.exists(system_test_folder_path):
627-
session.run(
628-
"py.test",
629-
"--verbose",
630-
f"--junitxml=system_{session.python}_sponge_log.xml",
631-
system_test_folder_path,
632-
*session.posargs,
633-
env={
634-
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635-
"SPANNER_DATABASE_DIALECT": database_dialect,
636-
"SKIP_BACKUP_TESTS": "true",
637-
},
638-
)
604+
# Sanity check: Only run system tests if credentials or emulator are set.
605+
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") or os.environ.get("SPANNER_EMULATOR_HOST"):
606+
# Only run system tests if found.
607+
if os.path.exists(system_test_path):
608+
session.run(
609+
"py.test",
610+
"--verbose",
611+
f"--junitxml=system_{session.python}_sponge_log.xml",
612+
system_test_path,
613+
*session.posargs,
614+
env={
615+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
616+
"SPANNER_DATABASE_DIALECT": database_dialect,
617+
"SKIP_BACKUP_TESTS": "true",
618+
},
619+
)
620+
elif os.path.exists(system_test_folder_path):
621+
session.run(
622+
"py.test",
623+
"--verbose",
624+
f"--junitxml=system_{session.python}_sponge_log.xml",
625+
system_test_folder_path,
626+
*session.posargs,
627+
env={
628+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
629+
"SPANNER_DATABASE_DIALECT": database_dialect,
630+
"SKIP_BACKUP_TESTS": "true",
631+
},
632+
)
633+
else:
634+
session.log("Skipping system tests because credentials/emulator are missing")
639635

640636
@nox.session(python=DEFAULT_PYTHON_VERSION)
641637
def mypy(session):

0 commit comments

Comments
 (0)