Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit 32ac434

Browse files
1 parent d2b62db commit 32ac434

File tree

1 file changed

+204
-0
lines changed

1 file changed

+204
-0
lines changed

noxfile.py

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import re
2424
import re
2525
import re
26+
import re
2627
import shutil
2728
from typing import Dict, List
2829
import warnings
@@ -33,6 +34,7 @@
3334
BLACK_VERSION = "black[jupyter]==23.7.0"
3435
ISORT_VERSION = "isort==5.11.0"
3536
LINT_PATHS = [
37+
"third_party",
3638
"third_party",
3739
"third_party",
3840
"docs",
@@ -123,6 +125,7 @@
123125
# Error if a python version is missing
124126
nox.options.stop_on_first_error = True
125127
nox.options.stop_on_first_error = True
128+
nox.options.stop_on_first_error = True
126129
nox.options.error_on_missing_interpreters = True
127130

128131

@@ -239,6 +242,14 @@ def unit(session, protobuf_implementation, install_extras=True):
239242
install_target = "."
240243
session.install("-e", install_target, "-c", constraints_path)
241244

245+
if install_extras and session.python in ["3.11", "3.12"]:
246+
install_target = ".[geography,alembic,tests,bqstorage]"
247+
elif install_extras:
248+
install_target = ".[all]"
249+
else:
250+
install_target = "."
251+
session.install("-e", install_target, "-c", constraints_path)
252+
242253
# TODO(https://github.com/googleapis/synthtool/issues/1976):
243254
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
244255
# The 'cpp' implementation requires Protobuf<4.
@@ -427,6 +438,195 @@ def system_noextras(session):
427438
)
428439

429440

441+
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
442+
def system_noextras(session):
443+
"""Run the system test suite."""
444+
constraints_path = str(
445+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
446+
)
447+
system_test_path = os.path.join("tests", "system.py")
448+
system_test_folder_path = os.path.join("tests", "system")
449+
450+
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
451+
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
452+
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
453+
# Install pyopenssl for mTLS testing.
454+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
455+
session.install("pyopenssl")
456+
457+
system_test_exists = os.path.exists(system_test_path)
458+
system_test_folder_exists = os.path.exists(system_test_folder_path)
459+
# Sanity check: only run tests if found.
460+
if not system_test_exists and not system_test_folder_exists:
461+
session.skip("System tests were not found")
462+
463+
global SYSTEM_TEST_EXTRAS_BY_PYTHON
464+
SYSTEM_TEST_EXTRAS_BY_PYTHON = False
465+
install_systemtest_dependencies(session, "-c", constraints_path)
466+
467+
# Run py.test against the system tests.
468+
if system_test_exists:
469+
session.run(
470+
"py.test",
471+
"--quiet",
472+
f"--junitxml=system_{session.python}_sponge_log.xml",
473+
system_test_path,
474+
*session.posargs,
475+
)
476+
if system_test_folder_exists:
477+
session.run(
478+
"py.test",
479+
"--quiet",
480+
f"--junitxml=system_{session.python}_sponge_log.xml",
481+
system_test_folder_path,
482+
*session.posargs,
483+
)
484+
485+
486+
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])
487+
def compliance(session):
488+
"""Run the SQLAlchemy dialect-compliance system tests"""
489+
constraints_path = str(
490+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
491+
)
492+
system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance")
493+
494+
if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false":
495+
session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping")
496+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
497+
session.install("pyopenssl")
498+
if not os.path.exists(system_test_folder_path):
499+
session.skip("Compliance tests were not found")
500+
501+
session.install(
502+
"mock",
503+
"pytest",
504+
"pytest-rerunfailures",
505+
"google-cloud-testutils",
506+
"-c",
507+
constraints_path,
508+
)
509+
if session.python == "3.8":
510+
extras = "[tests,alembic]"
511+
elif session.python in ["3.11", "3.12"]:
512+
extras = "[tests,geography]"
513+
else:
514+
extras = "[tests]"
515+
session.install("-e", f".{extras}", "-c", constraints_path)
516+
517+
session.run("python", "-m", "pip", "freeze")
518+
519+
session.run(
520+
"py.test",
521+
"-vv",
522+
f"--junitxml=compliance_{session.python}_sponge_log.xml",
523+
"--reruns=3",
524+
"--reruns-delay=60",
525+
"--only-rerun=Exceeded rate limits",
526+
"--only-rerun=Already Exists",
527+
"--only-rerun=Not found",
528+
"--only-rerun=Cannot execute DML over a non-existent table",
529+
"--only-rerun=Job exceeded rate limits",
530+
system_test_folder_path,
531+
*session.posargs,
532+
# To suppress the "Deprecated API features detected!" warning when
533+
# features not compatible with 2.0 are detected, use a value of "1"
534+
env={
535+
"SQLALCHEMY_SILENCE_UBER_WARNING": "1",
536+
},
537+
)
538+
539+
540+
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
541+
def system_noextras(session):
542+
"""Run the system test suite."""
543+
constraints_path = str(
544+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
545+
)
546+
system_test_path = os.path.join("tests", "system.py")
547+
system_test_folder_path = os.path.join("tests", "system")
548+
549+
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
550+
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
551+
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
552+
# Install pyopenssl for mTLS testing.
553+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
554+
session.install("pyopenssl")
555+
556+
system_test_exists = os.path.exists(system_test_path)
557+
system_test_folder_exists = os.path.exists(system_test_folder_path)
558+
# Sanity check: only run tests if found.
559+
if not system_test_exists and not system_test_folder_exists:
560+
session.skip("System tests were not found")
561+
562+
global SYSTEM_TEST_EXTRAS_BY_PYTHON
563+
SYSTEM_TEST_EXTRAS_BY_PYTHON = False
564+
install_systemtest_dependencies(session, "-c", constraints_path)
565+
566+
# Run py.test against the system tests.
567+
if system_test_exists:
568+
session.run(
569+
"py.test",
570+
"--quiet",
571+
f"--junitxml=system_{session.python}_sponge_log.xml",
572+
system_test_path,
573+
*session.posargs,
574+
)
575+
if system_test_folder_exists:
576+
session.run(
577+
"py.test",
578+
"--quiet",
579+
f"--junitxml=system_{session.python}_sponge_log.xml",
580+
system_test_folder_path,
581+
*session.posargs,
582+
)
583+
584+
585+
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
586+
def system_noextras(session):
587+
"""Run the system test suite."""
588+
constraints_path = str(
589+
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
590+
)
591+
system_test_path = os.path.join("tests", "system.py")
592+
system_test_folder_path = os.path.join("tests", "system")
593+
594+
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
595+
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
596+
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
597+
# Install pyopenssl for mTLS testing.
598+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
599+
session.install("pyopenssl")
600+
601+
system_test_exists = os.path.exists(system_test_path)
602+
system_test_folder_exists = os.path.exists(system_test_folder_path)
603+
# Sanity check: only run tests if found.
604+
if not system_test_exists and not system_test_folder_exists:
605+
session.skip("System tests were not found")
606+
607+
global SYSTEM_TEST_EXTRAS_BY_PYTHON
608+
SYSTEM_TEST_EXTRAS_BY_PYTHON = False
609+
install_systemtest_dependencies(session, "-c", constraints_path)
610+
611+
# Run py.test against the system tests.
612+
if system_test_exists:
613+
session.run(
614+
"py.test",
615+
"--quiet",
616+
f"--junitxml=system_{session.python}_sponge_log.xml",
617+
system_test_path,
618+
*session.posargs,
619+
)
620+
if system_test_folder_exists:
621+
session.run(
622+
"py.test",
623+
"--quiet",
624+
f"--junitxml=system_{session.python}_sponge_log.xml",
625+
system_test_folder_path,
626+
*session.posargs,
627+
)
628+
629+
430630
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1])
431631
def compliance(session):
432632
"""Run the SQLAlchemy dialect-compliance system tests"""
@@ -614,6 +814,8 @@ def docs(session):
614814
"shapely",
615815
"geoalchemy2",
616816
"shapely",
817+
"geoalchemy2",
818+
"shapely",
617819
"recommonmark",
618820
)
619821

@@ -653,6 +855,8 @@ def docfx(session):
653855
"shapely",
654856
"geoalchemy2",
655857
"shapely",
858+
"geoalchemy2",
859+
"shapely",
656860
"recommonmark",
657861
)
658862

0 commit comments

Comments
 (0)