Skip to content

wip#17319

Draft
ohmayr wants to merge 6 commits into
mainfrom
centralize-gapic-testing
Draft

wip#17319
ohmayr wants to merge 6 commits into
mainfrom
centralize-gapic-testing

Conversation

@ohmayr
Copy link
Copy Markdown
Contributor

@ohmayr ohmayr commented May 29, 2026

wip

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the prerelease_deps session in noxfile.py to run generated unit tests against pre-release ecosystem dependencies. The feedback suggests using importlib.metadata to retrieve package versions more robustly without importing the packages directly, and replacing the deprecated py.test command with pytest.

Comment on lines +866 to +880
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}
for pkg, namespace in package_namespaces.items():
session.run(
"python",
"-c",
f"import {namespace}; print('{pkg}:', {namespace}.__version__)",
silent=False,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using importlib.metadata is a more robust and standard way to retrieve installed package versions. It avoids importing the packages directly (which can trigger deprecation warnings or initialization side-effects) and eliminates the need to map package names to their internal import namespaces.

Suggested change
package_namespaces = {
"google-api-core": "google.api_core",
"google-auth": "google.auth",
"grpcio": "grpc",
"protobuf": "google.protobuf",
"proto-plus": "proto",
}
for pkg, namespace in package_namespaces.items():
session.run(
"python",
"-c",
f"import {namespace}; print('{pkg}:', {namespace}.__version__)",
silent=False,
)
# 3. Print out the versions to mimic the downstream logging verification
packages = [
"google-api-core",
"google-auth",
"grpcio",
"protobuf",
"proto-plus",
]
for pkg in packages:
session.run(
"python",
"-c",
f"import importlib.metadata; print('{pkg}:', importlib.metadata.version('{pkg}'))",
)

Comment on lines +881 to +888
# 4. Run the hermetic unit tests with the specific protobuf backend
session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use pytest instead of the deprecated py.test entry point to run the unit tests.

Suggested change
# 4. Run the hermetic unit tests with the specific protobuf backend
session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)
# 4. Run the hermetic unit tests with the specific protobuf backend
session.run(
"pytest",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant