|
31 | 31 |
|
32 | 32 | DEFAULT_PYTHON_VERSION = "3.8"
|
33 | 33 |
|
| 34 | + |
34 | 35 | UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
35 | 36 | UNIT_TEST_STANDARD_DEPENDENCIES = [
|
36 | 37 | "mock",
|
|
51 | 52 | "3.9": [],
|
52 | 53 | }
|
53 | 54 |
|
| 55 | +CONDA_TEST_PYTHON_VERSIONS = [ |
| 56 | + UNIT_TEST_PYTHON_VERSIONS[0], |
| 57 | + UNIT_TEST_PYTHON_VERSIONS[-1], |
| 58 | +] |
| 59 | + |
54 | 60 | SYSTEM_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
55 | 61 | SYSTEM_TEST_STANDARD_DEPENDENCIES = [
|
56 | 62 | "mock",
|
@@ -514,3 +520,78 @@ def prerelease_deps(session):
|
514 | 520 | system_test_folder_path,
|
515 | 521 | *session.posargs,
|
516 | 522 | )
|
| 523 | + |
| 524 | + |
| 525 | +def install_conda_unittest_dependencies(session, standard_deps, conda_forge_packages): |
| 526 | + """Installs packages from conda forge, pypi, and locally.""" |
| 527 | + |
| 528 | + # Install from conda-forge and default conda package repos. |
| 529 | + session.conda_install(*conda_forge_packages, channel=["defaults", "conda-forge"]) |
| 530 | + |
| 531 | + # Install from pypi for packages not readily available on conda forge. |
| 532 | + session.install( |
| 533 | + *standard_deps, |
| 534 | + ) |
| 535 | + |
| 536 | + # Install via pip from the local repo, avoid doing dependency resolution |
| 537 | + # via pip, so that we don't override any conda resolved dependencies |
| 538 | + session.install("-e", ".", "--no-deps") |
| 539 | + |
| 540 | + |
| 541 | +@nox.session(python=CONDA_TEST_PYTHON_VERSIONS, venv_backend="mamba") |
| 542 | +def conda_test(session): |
| 543 | + """Run test suite in a conda virtual environment. |
| 544 | +
|
| 545 | + Installs all test dependencies, then installs this package. |
| 546 | + NOTE: Some of these libraries are not readily available on conda-forge |
| 547 | + at this time and are thus installed using pip after the base install of |
| 548 | + libraries from conda-forge. |
| 549 | +
|
| 550 | + We decided that it was more important to prove a base ability to install |
| 551 | + using conda than to complicate things with adding a whole nother |
| 552 | + set of constraints just for a conda install, so this install does not |
| 553 | + attempt to constrain packages (i.e. in a constraints-x.x.txt file) |
| 554 | + manually. |
| 555 | + """ |
| 556 | + |
| 557 | + standard_deps = ( |
| 558 | + UNIT_TEST_STANDARD_DEPENDENCIES |
| 559 | + + UNIT_TEST_DEPENDENCIES |
| 560 | + + UNIT_TEST_EXTERNAL_DEPENDENCIES |
| 561 | + ) |
| 562 | + |
| 563 | + conda_forge_packages = [ |
| 564 | + "db-dtypes", |
| 565 | + "google-api-core", |
| 566 | + "google-auth", |
| 567 | + "google-auth-oauthlib", |
| 568 | + "google-cloud-bigquery", |
| 569 | + "google-cloud-bigquery-storage", |
| 570 | + "numpy", |
| 571 | + "pandas", |
| 572 | + "pyarrow", |
| 573 | + "pydata-google-auth", |
| 574 | + "tqdm", |
| 575 | + "protobuf", |
| 576 | + ] |
| 577 | + |
| 578 | + install_conda_unittest_dependencies(session, standard_deps, conda_forge_packages) |
| 579 | + |
| 580 | + # Provide a list of all installed packages (both from conda forge and pip) |
| 581 | + # for troubleshooting purposes. |
| 582 | + session.run("mamba", "list") |
| 583 | + |
| 584 | + # Tests are limited to unit tests only, at this time. |
| 585 | + session.run( |
| 586 | + "py.test", |
| 587 | + "--quiet", |
| 588 | + f"--junitxml=unit_{session.python}_sponge_log.xml", |
| 589 | + "--cov=pandas_gbq", |
| 590 | + "--cov=tests/unit", |
| 591 | + "--cov-append", |
| 592 | + "--cov-config=.coveragerc", |
| 593 | + "--cov-report=", |
| 594 | + "--cov-fail-under=0", |
| 595 | + os.path.join("tests", "unit"), |
| 596 | + *session.posargs, |
| 597 | + ) |
0 commit comments