Skip to content

chore: clean environment for datastore tests#16734

Merged
ohmayr merged 1 commit intomainfrom
fix-datastore-tests
Apr 20, 2026
Merged

chore: clean environment for datastore tests#16734
ohmayr merged 1 commit intomainfrom
fix-datastore-tests

Conversation

@ohmayr
Copy link
Copy Markdown
Contributor

@ohmayr ohmayr commented Apr 20, 2026

clean environment for datastore tests

@ohmayr ohmayr requested a review from a team as a code owner April 20, 2026 20:52
@ohmayr ohmayr force-pushed the fix-datastore-tests branch from 78c59bd to cc8e382 Compare April 20, 2026 20:53
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 introduces environment variable isolation for client constructor tests by using @mock.patch.dict(os.environ, clear=True). However, the removal of test_client_ctor_w_explicit_inputs significantly reduces test coverage for explicit parameter handling. This test should be restored and updated to correctly utilize the database_id parameter instead of a hardcoded value.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/google-cloud-datastore/tests/unit/test_client.py (164-192)

high

The test test_client_ctor_w_explicit_inputs is being removed without explanation in the pull request description. This test provides critical coverage for verifying that the Client correctly handles explicitly provided arguments (such as project, database, and credentials), which is a distinct logic path from the implicit discovery tested in other cases. If this test was failing due to environment variable interference, it should be retained and patched with @mock.patch.dict(os.environ, clear=True) rather than deleted.

Additionally, if restored, please address the bug where the test ignores the parametrized database_id and instead uses a hardcoded "database" string (line 169).

@ohmayr ohmayr merged commit eba633c into main Apr 20, 2026
30 checks passed
@ohmayr ohmayr deleted the fix-datastore-tests branch April 20, 2026 21:12
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.

2 participants