2020import multiprocessing
2121import os
2222import pathlib
23- import re
2423import shutil
2524import time
2625from typing import Dict , List
6261 "pytest-cov" ,
6362 "pytest-timeout" ,
6463]
65- UNIT_TEST_EXTERNAL_DEPENDENCIES : List [str ] = []
6664UNIT_TEST_DEPENDENCIES : List [str ] = []
6765UNIT_TEST_EXTRAS : List [str ] = ["tests" ]
6866UNIT_TEST_EXTRAS_BY_PYTHON : Dict [str , List [str ]] = {
9593SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [
9694 "google-cloud-bigquery" ,
9795]
98- SYSTEM_TEST_EXTRAS : List [str ] = []
96+ SYSTEM_TEST_EXTRAS : List [str ] = ["tests" ]
9997SYSTEM_TEST_EXTRAS_BY_PYTHON : Dict [str , List [str ]] = {
10098 # Make sure we leave some versions without "extras" so we know those
10199 # dependencies are actually optional.
@@ -191,15 +189,6 @@ def format(session):
191189 * LINT_PATHS ,
192190 )
193191
194- # 3. Run Ruff to format code
195- session .run (
196- "ruff" ,
197- "format" ,
198- f"--target-version=py{ ALL_PYTHON [0 ].replace ('.' , '' )} " ,
199- "--line-length=88" , # Standard Black line length
200- * LINT_PATHS ,
201- )
202-
203192
204193@nox .session (python = DEFAULT_PYTHON_VERSION )
205194def lint_setup_py (session ):
@@ -266,14 +255,10 @@ def run_unit(session, install_test_extra):
266255
267256
268257@nox .session (python = ALL_PYTHON )
269- @nox .parametrize ("test_extra" , [True , False ])
270- def unit (session , test_extra ):
258+ def unit (session ):
271259 if session .python in ("3.7" , "3.8" , "3.9" ):
272260 session .skip ("Python 3.9 and below are not supported" )
273- if test_extra :
274- run_unit (session , install_test_extra = test_extra )
275- else :
276- unit_noextras (session )
261+ run_unit (session , install_test_extra = True )
277262
278263
279264@nox .session (python = ALL_PYTHON [- 1 ])
@@ -376,15 +361,14 @@ def run_system(
376361@nox .session (python = "3.12" )
377362def system (session : nox .sessions .Session ):
378363 """Run the system test suite."""
379- if session .python in ("3.7" , "3.8" , "3.9" ):
380- session .skip ("Python 3.9 and below are not supported" )
381-
364+ # TODO(https://github.com/googleapis/google-cloud-python/issues/16489): Restore system test once this bug is fixed
382365 run_system (
383366 session = session ,
384367 prefix_name = "system" ,
385368 test_folder = os .path .join ("tests" , "system" , "small" ),
386369 check_cov = True ,
387370 )
371+ # session.skip("Temporarily skip system test")
388372
389373
390374@nox .session (python = DEFAULT_PYTHON_VERSION )
@@ -401,10 +385,6 @@ def system_noextras(session: nox.sessions.Session):
401385@nox .session (python = "3.12" )
402386def doctest (session : nox .sessions .Session ):
403387 """Run the system test suite."""
404- session .skip (
405- "Temporary skip to enable a PR merge. Remove skip as part of closing https://github.com/googleapis/google-cloud-python/issues/16489"
406- )
407-
408388 run_system (
409389 session = session ,
410390 prefix_name = "doctest" ,
@@ -460,10 +440,6 @@ def cover(session):
460440 This outputs the coverage report aggregating coverage from the test runs
461441 (including system test runs), and then erases coverage data.
462442 """
463- # TODO: Remove this skip when the issue is resolved.
464- # https://github.com/googleapis/google-cloud-python/issues/16635
465- session .skip ("Temporarily skip coverage session" )
466-
467443 session .install ("coverage" , "pytest-cov" )
468444
469445 # Create a coverage report that includes only the product code.
@@ -945,129 +921,69 @@ def cleanup(session):
945921
946922
947923@nox .session (python = DEFAULT_PYTHON_VERSION )
948- @nox .parametrize (
949- "protobuf_implementation" ,
950- ["python" , "upb" ],
951- )
952- def core_deps_from_source (session , protobuf_implementation ):
924+ def core_deps_from_source (session ):
953925 """Run all tests with core dependencies installed from source
954926 rather than pulling the dependencies from PyPI.
955927 """
956-
957- # Install all dependencies
958- session .install ("-e" , "." )
959-
960- # Install dependencies for the unit test environment
961- unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
962- session .install (* unit_deps_all )
963-
964- # Install dependencies for the system test environment
965- system_deps_all = (
966- SYSTEM_TEST_STANDARD_DEPENDENCIES
967- + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
968- + SYSTEM_TEST_EXTRAS
969- )
970- session .install (* system_deps_all )
971-
972- # Because we test minimum dependency versions on the minimum Python
973- # version, the first version we test with in the unit tests sessions has a
974- # constraints file containing all dependencies and extras.
975- with open (
976- CURRENT_DIRECTORY / "testing" / "constraints-3.10.txt" ,
977- encoding = "utf-8" ,
978- ) as constraints_file :
979- constraints_text = constraints_file .read ()
980-
981- # Ignore leading whitespace and comment lines.
982- # Fiona fails to build on GitHub CI because gdal-config is missing and no Python 3.14 wheels are available.
983- constraints_deps = [
984- match .group (1 )
985- for match in re .finditer (
986- r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
987- )
988- if match .group (1 ) != "fiona"
989- ]
990-
991- # Install dependencies specified in `testing/constraints-X.txt`.
992- session .install (* constraints_deps )
993-
994- # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and
995- # `grpcio-status` should be added to the list below so that they are installed from source,
996- # rather than PyPI.
997- # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be
998- # added to the list below so that it is installed from source, rather than PyPI
999- # Note: If a dependency is added to the `core_dependencies_from_source` list,
1000- # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
1001- core_dependencies_from_source = [
1002- "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos" ,
1003- "google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core" ,
1004- "google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth" ,
1005- "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1" ,
1006- "proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus" ,
1007- ]
1008-
1009- for dep in core_dependencies_from_source :
1010- session .install (dep , "--no-deps" , "--ignore-installed" )
1011- print (f"Installed { dep } " )
1012-
1013- session .run (
1014- "py.test" ,
1015- "tests/unit" ,
1016- env = {
1017- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
1018- },
1019- )
928+ # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
929+ # Add core deps from source tests
930+ session .skip ("Core deps from source tests are not yet supported" )
1020931
1021932
1022- @nox .session (python = ALL_PYTHON [ - 1 ] )
933+ @nox .session (python = DEFAULT_PYTHON_VERSION )
1023934def prerelease_deps (session ):
1024935 """Run all tests with prerelease versions of dependencies installed."""
1025936 # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
1026937 # Add prerelease deps tests
1027- unit_prerelease (session )
1028- system_prerelease (session )
938+ session .skip ("prerelease deps tests are not yet supported" )
1029939
1030940
1031- # NOTE: this is based on mypy session that came directly from the bigframes split repo
1032- # the split repo used 3.10, the monorepo uses 3.14
1033- @nox .session (python = "3.14" )
941+ @nox .session (python = DEFAULT_PYTHON_VERSION )
1034942def mypy (session ):
1035- """Run type checks with mypy."""
1036- # Editable mode is not compatible with mypy when there are multiple
1037- # package directories. See:
1038- # https://github.com/python/mypy/issues/10564#issuecomment-851687749
1039- session .install ("." )
1040-
1041- # Just install the dependencies' type info directly, since "mypy --install-types"
1042- # might require an additional pass.
1043- deps = (
1044- set (
1045- [
1046- MYPY_VERSION ,
1047- # TODO: update to latest pandas-stubs once we resolve bigframes issues.
1048- "pandas-stubs<=2.2.3.241126" ,
1049- "types-protobuf" ,
1050- "types-python-dateutil" ,
1051- "types-requests" ,
1052- "types-setuptools" ,
1053- "types-tabulate" ,
1054- "types-PyYAML" ,
1055- "polars" ,
1056- "anywidget" ,
1057- ]
1058- )
1059- | set (SYSTEM_TEST_STANDARD_DEPENDENCIES )
1060- | set (UNIT_TEST_STANDARD_DEPENDENCIES )
1061- )
1062-
1063- session .install (* deps )
1064- shutil .rmtree (".mypy_cache" , ignore_errors = True )
1065- session .run (
1066- "mypy" ,
1067- "bigframes" ,
1068- os .path .join ("tests" , "system" ),
1069- os .path .join ("tests" , "unit" ),
1070- "--check-untyped-defs" ,
1071- "--explicit-package-bases" ,
1072- '--exclude="^third_party"' ,
1073- )
943+ """Run the type checker."""
944+ # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
945+ # Add mypy tests previously used mypy session (below) failed to run in the monorepo
946+ session .skip ("mypy tests are not yet supported" )
947+
948+
949+ # @nox.session(python=ALL_PYTHON)
950+ # def mypy(session):
951+ # """Run type checks with mypy."""
952+ # # Editable mode is not compatible with mypy when there are multiple
953+ # # package directories. See:
954+ # # https://github.com/python/mypy/issues/10564#issuecomment-851687749
955+ # session.install(".")
956+
957+ # # Just install the dependencies' type info directly, since "mypy --install-types"
958+ # # might require an additional pass.
959+ # deps = (
960+ # set(
961+ # [
962+ # MYPY_VERSION,
963+ # # TODO: update to latest pandas-stubs once we resolve bigframes issues.
964+ # "pandas-stubs<=2.2.3.241126",
965+ # "types-protobuf",
966+ # "types-python-dateutil",
967+ # "types-requests",
968+ # "types-setuptools",
969+ # "types-tabulate",
970+ # "types-PyYAML",
971+ # "polars",
972+ # "anywidget",
973+ # ]
974+ # )
975+ # | set(SYSTEM_TEST_STANDARD_DEPENDENCIES)
976+ # | set(UNIT_TEST_STANDARD_DEPENDENCIES)
977+ # )
978+
979+ # session.install(*deps)
980+ # shutil.rmtree(".mypy_cache", ignore_errors=True)
981+ # session.run(
982+ # "mypy",
983+ # "bigframes",
984+ # os.path.join("tests", "system"),
985+ # os.path.join("tests", "unit"),
986+ # "--check-untyped-defs",
987+ # "--explicit-package-bases",
988+ # '--exclude="^third_party"',
989+ # )
0 commit comments