@@ -920,13 +920,76 @@ def cleanup(session):
920920
921921
922922@nox .session (python = DEFAULT_PYTHON_VERSION )
923- def core_deps_from_source (session ):
923+ @nox .parametrize (
924+ "protobuf_implementation" ,
925+ ["python" , "upb" ],
926+ )
927+ def core_deps_from_source (session , protobuf_implementation ):
924928 """Run all tests with core dependencies installed from source
925929 rather than pulling the dependencies from PyPI.
926930 """
927- # TODO(https://github.com/googleapis/google-cloud-python/issues/16014):
928- # Add core deps from source tests
929- session .skip ("Core deps from source tests are not yet supported" )
931+
932+ # Install all dependencies
933+ session .install ("-e" , "." )
934+
935+ # Install dependencies for the unit test environment
936+ unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
937+ session .install (* unit_deps_all )
938+
939+ # Install dependencies for the system test environment
940+ system_deps_all = (
941+ SYSTEM_TEST_STANDARD_DEPENDENCIES
942+ + SYSTEM_TEST_EXTERNAL_DEPENDENCIES
943+ + SYSTEM_TEST_EXTRAS
944+ )
945+ session .install (* system_deps_all )
946+
947+ # Because we test minimum dependency versions on the minimum Python
948+ # version, the first version we test with in the unit tests sessions has a
949+ # constraints file containing all dependencies and extras.
950+ with open (
951+ CURRENT_DIRECTORY / "testing" / f"constraints-{ ALL_PYTHON [0 ]} .txt" ,
952+ encoding = "utf-8" ,
953+ ) as constraints_file :
954+ constraints_text = constraints_file .read ()
955+
956+ # Ignore leading whitespace and comment lines.
957+ constraints_deps = [
958+ match .group (1 )
959+ for match in re .finditer (
960+ r"^\s*(\S+)(?===\S+)" , constraints_text , flags = re .MULTILINE
961+ )
962+ ]
963+
964+ # Install dependencies specified in `testing/constraints-X.txt`.
965+ session .install (* constraints_deps )
966+
967+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and
968+ # `grpcio-status` should be added to the list below so that they are installed from source,
969+ # rather than PyPI.
970+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be
971+ # added to the list below so that it is installed from source, rather than PyPI
972+ # Note: If a dependency is added to the `core_dependencies_from_source` list,
973+ # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated.
974+ core_dependencies_from_source = [
975+ "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos" ,
976+ "google-api-core @ git+https://github.com/googleapis/google-cloud-python#egg=google-api-core&subdirectory=packages/google-api-core" ,
977+ "google-auth @ git+https://github.com/googleapis/google-cloud-python#egg=google-auth&subdirectory=packages/google-auth" ,
978+ "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1" ,
979+ "proto-plus @ git+https://github.com/googleapis/google-cloud-python#egg=proto-plus&subdirectory=packages/proto-plus" ,
980+ ]
981+
982+ for dep in core_dependencies_from_source :
983+ session .install (dep , "--no-deps" , "--ignore-installed" )
984+ print (f"Installed { dep } " )
985+
986+ session .run (
987+ "py.test" ,
988+ "tests/unit" ,
989+ env = {
990+ "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" : protobuf_implementation ,
991+ },
992+ )
930993
931994
932995@nox .session (python = ALL_PYTHON [- 1 ])
0 commit comments