|
23 | 23 | import re |
24 | 24 | import re |
25 | 25 | import re |
| 26 | +import re |
26 | 27 | import shutil |
27 | 28 | from typing import Dict, List |
28 | 29 | import warnings |
|
33 | 34 | BLACK_VERSION = "black[jupyter]==23.7.0" |
34 | 35 | ISORT_VERSION = "isort==5.11.0" |
35 | 36 | LINT_PATHS = [ |
| 37 | + "third_party", |
36 | 38 | "third_party", |
37 | 39 | "third_party", |
38 | 40 | "docs", |
|
123 | 125 | # Error if a python version is missing |
124 | 126 | nox.options.stop_on_first_error = True |
125 | 127 | nox.options.stop_on_first_error = True |
| 128 | +nox.options.stop_on_first_error = True |
126 | 129 | nox.options.error_on_missing_interpreters = True |
127 | 130 |
|
128 | 131 |
|
@@ -239,6 +242,14 @@ def unit(session, protobuf_implementation, install_extras=True): |
239 | 242 | install_target = "." |
240 | 243 | session.install("-e", install_target, "-c", constraints_path) |
241 | 244 |
|
| 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 | + |
242 | 253 | # TODO(https://github.com/googleapis/synthtool/issues/1976): |
243 | 254 | # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. |
244 | 255 | # The 'cpp' implementation requires Protobuf<4. |
@@ -427,6 +438,195 @@ def system_noextras(session): |
427 | 438 | ) |
428 | 439 |
|
429 | 440 |
|
| 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 | + |
430 | 630 | @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS[-1]) |
431 | 631 | def compliance(session): |
432 | 632 | """Run the SQLAlchemy dialect-compliance system tests""" |
@@ -614,6 +814,8 @@ def docs(session): |
614 | 814 | "shapely", |
615 | 815 | "geoalchemy2", |
616 | 816 | "shapely", |
| 817 | + "geoalchemy2", |
| 818 | + "shapely", |
617 | 819 | "recommonmark", |
618 | 820 | ) |
619 | 821 |
|
@@ -653,6 +855,8 @@ def docfx(session): |
653 | 855 | "shapely", |
654 | 856 | "geoalchemy2", |
655 | 857 | "shapely", |
| 858 | + "geoalchemy2", |
| 859 | + "shapely", |
656 | 860 | "recommonmark", |
657 | 861 | ) |
658 | 862 |
|
|
0 commit comments