|
22 | 22 | import pathlib |
23 | 23 | import re |
24 | 24 | import re |
| 25 | +import re |
25 | 26 | import shutil |
26 | 27 | from typing import Dict, List |
27 | 28 | import warnings |
|
32 | 33 | BLACK_VERSION = "black[jupyter]==23.7.0" |
33 | 34 | ISORT_VERSION = "isort==5.11.0" |
34 | 35 | LINT_PATHS = [ |
| 36 | + "third_party", |
35 | 37 | "third_party", |
36 | 38 | "docs", |
37 | 39 | "sqlalchemy_bigquery", |
|
120 | 122 |
|
121 | 123 | # Error if a python version is missing |
122 | 124 | nox.options.stop_on_first_error = True |
| 125 | +nox.options.stop_on_first_error = True |
123 | 126 | nox.options.error_on_missing_interpreters = True |
124 | 127 |
|
125 | 128 |
|
@@ -228,6 +231,14 @@ def unit(session, protobuf_implementation, install_extras=True): |
228 | 231 | install_target = "." |
229 | 232 | session.install("-e", install_target, "-c", constraints_path) |
230 | 233 |
|
| 234 | + if install_extras and session.python in ["3.11", "3.12"]: |
| 235 | + install_target = ".[geography,alembic,tests,bqstorage]" |
| 236 | + elif install_extras: |
| 237 | + install_target = ".[all]" |
| 238 | + else: |
| 239 | + install_target = "." |
| 240 | + session.install("-e", install_target, "-c", constraints_path) |
| 241 | + |
231 | 242 | # TODO(https://github.com/googleapis/synthtool/issues/1976): |
232 | 243 | # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. |
233 | 244 | # The 'cpp' implementation requires Protobuf<4. |
@@ -371,6 +382,150 @@ def system_noextras(session): |
371 | 382 | ) |
372 | 383 |
|
373 | 384 |
|
| 385 | +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) |
| 386 | +def system_noextras(session): |
| 387 | + """Run the system test suite.""" |
| 388 | + constraints_path = str( |
| 389 | + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" |
| 390 | + ) |
| 391 | + system_test_path = os.path.join("tests", "system.py") |
| 392 | + system_test_folder_path = os.path.join("tests", "system") |
| 393 | + |
| 394 | + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. |
| 395 | + if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": |
| 396 | + session.skip("RUN_SYSTEM_TESTS is set to false, skipping") |
| 397 | + # Install pyopenssl for mTLS testing. |
| 398 | + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": |
| 399 | + session.install("pyopenssl") |
| 400 | + |
| 401 | + system_test_exists = os.path.exists(system_test_path) |
| 402 | + system_test_folder_exists = os.path.exists(system_test_folder_path) |
| 403 | + # Sanity check: only run tests if found. |
| 404 | + if not system_test_exists and not system_test_folder_exists: |
| 405 | + session.skip("System tests were not found") |
| 406 | + |
| 407 | + global SYSTEM_TEST_EXTRAS_BY_PYTHON |
| 408 | + SYSTEM_TEST_EXTRAS_BY_PYTHON = False |
| 409 | + install_systemtest_dependencies(session, "-c", constraints_path) |
| 410 | + |
| 411 | + # Run py.test against the system tests. |
| 412 | + if system_test_exists: |
| 413 | + session.run( |
| 414 | + "py.test", |
| 415 | + "--quiet", |
| 416 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 417 | + system_test_path, |
| 418 | + *session.posargs, |
| 419 | + ) |
| 420 | + if system_test_folder_exists: |
| 421 | + session.run( |
| 422 | + "py.test", |
| 423 | + "--quiet", |
| 424 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 425 | + system_test_folder_path, |
| 426 | + *session.posargs, |
| 427 | + ) |
| 428 | + |
| 429 | + |
| 430 | +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1]) |
| 431 | +def compliance(session): |
| 432 | + """Run the SQLAlchemy dialect-compliance system tests""" |
| 433 | + constraints_path = str( |
| 434 | + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" |
| 435 | + ) |
| 436 | + system_test_folder_path = os.path.join("tests", "sqlalchemy_dialect_compliance") |
| 437 | + |
| 438 | + if os.environ.get("RUN_COMPLIANCE_TESTS", "true") == "false": |
| 439 | + session.skip("RUN_COMPLIANCE_TESTS is set to false, skipping") |
| 440 | + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": |
| 441 | + session.install("pyopenssl") |
| 442 | + if not os.path.exists(system_test_folder_path): |
| 443 | + session.skip("Compliance tests were not found") |
| 444 | + |
| 445 | + session.install( |
| 446 | + "mock", |
| 447 | + "pytest", |
| 448 | + "pytest-rerunfailures", |
| 449 | + "google-cloud-testutils", |
| 450 | + "-c", |
| 451 | + constraints_path, |
| 452 | + ) |
| 453 | + if session.python == "3.8": |
| 454 | + extras = "[tests,alembic]" |
| 455 | + elif session.python in ["3.11", "3.12"]: |
| 456 | + extras = "[tests,geography]" |
| 457 | + else: |
| 458 | + extras = "[tests]" |
| 459 | + session.install("-e", f".{extras}", "-c", constraints_path) |
| 460 | + |
| 461 | + session.run("python", "-m", "pip", "freeze") |
| 462 | + |
| 463 | + session.run( |
| 464 | + "py.test", |
| 465 | + "-vv", |
| 466 | + f"--junitxml=compliance_{session.python}_sponge_log.xml", |
| 467 | + "--reruns=3", |
| 468 | + "--reruns-delay=60", |
| 469 | + "--only-rerun=Exceeded rate limits", |
| 470 | + "--only-rerun=Already Exists", |
| 471 | + "--only-rerun=Not found", |
| 472 | + "--only-rerun=Cannot execute DML over a non-existent table", |
| 473 | + "--only-rerun=Job exceeded rate limits", |
| 474 | + system_test_folder_path, |
| 475 | + *session.posargs, |
| 476 | + # To suppress the "Deprecated API features detected!" warning when |
| 477 | + # features not compatible with 2.0 are detected, use a value of "1" |
| 478 | + env={ |
| 479 | + "SQLALCHEMY_SILENCE_UBER_WARNING": "1", |
| 480 | + }, |
| 481 | + ) |
| 482 | + |
| 483 | + |
| 484 | +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) |
| 485 | +def system_noextras(session): |
| 486 | + """Run the system test suite.""" |
| 487 | + constraints_path = str( |
| 488 | + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" |
| 489 | + ) |
| 490 | + system_test_path = os.path.join("tests", "system.py") |
| 491 | + system_test_folder_path = os.path.join("tests", "system") |
| 492 | + |
| 493 | + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. |
| 494 | + if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": |
| 495 | + session.skip("RUN_SYSTEM_TESTS is set to false, skipping") |
| 496 | + # Install pyopenssl for mTLS testing. |
| 497 | + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": |
| 498 | + session.install("pyopenssl") |
| 499 | + |
| 500 | + system_test_exists = os.path.exists(system_test_path) |
| 501 | + system_test_folder_exists = os.path.exists(system_test_folder_path) |
| 502 | + # Sanity check: only run tests if found. |
| 503 | + if not system_test_exists and not system_test_folder_exists: |
| 504 | + session.skip("System tests were not found") |
| 505 | + |
| 506 | + global SYSTEM_TEST_EXTRAS_BY_PYTHON |
| 507 | + SYSTEM_TEST_EXTRAS_BY_PYTHON = False |
| 508 | + install_systemtest_dependencies(session, "-c", constraints_path) |
| 509 | + |
| 510 | + # Run py.test against the system tests. |
| 511 | + if system_test_exists: |
| 512 | + session.run( |
| 513 | + "py.test", |
| 514 | + "--quiet", |
| 515 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 516 | + system_test_path, |
| 517 | + *session.posargs, |
| 518 | + ) |
| 519 | + if system_test_folder_exists: |
| 520 | + session.run( |
| 521 | + "py.test", |
| 522 | + "--quiet", |
| 523 | + f"--junitxml=system_{session.python}_sponge_log.xml", |
| 524 | + system_test_folder_path, |
| 525 | + *session.posargs, |
| 526 | + ) |
| 527 | + |
| 528 | + |
374 | 529 | @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1]) |
375 | 530 | def compliance(session): |
376 | 531 | """Run the SQLAlchemy dialect-compliance system tests""" |
@@ -457,6 +612,8 @@ def docs(session): |
457 | 612 | "alabaster", |
458 | 613 | "geoalchemy2", |
459 | 614 | "shapely", |
| 615 | + "geoalchemy2", |
| 616 | + "shapely", |
460 | 617 | "recommonmark", |
461 | 618 | ) |
462 | 619 |
|
@@ -494,6 +651,8 @@ def docfx(session): |
494 | 651 | "alabaster", |
495 | 652 | "geoalchemy2", |
496 | 653 | "shapely", |
| 654 | + "geoalchemy2", |
| 655 | + "shapely", |
497 | 656 | "recommonmark", |
498 | 657 | ) |
499 | 658 |
|
|
0 commit comments