chore: clean environment for datastore tests#16734
Conversation
78c59bd to
cc8e382
Compare
There was a problem hiding this comment.
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)
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).
clean environment for datastore tests