Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to ensure that the rpc is being retried, but not that it's using the retry configuration that was actually passed in.
If a regression made it fall back to DEFAULT_RETRY in the handwritten layer, or even the default retry configured in the gapic layer like before, wouldn't the tests still pass? Or is that tested elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent some time thinking about this PR.
Began to doubt whether checking the
client._connection.api_request()(e.g.conn.api_request) method was the right way to go.Turns out, the
client._call_api()method wraps the call toclient._connection.api_request(). Theretryobject is used by_call_apito manage any needed retries, but theretryobject itself is NOT passed as a direct argument toclient._connection.api_request. Nor is it expected to be.Here's what we did:
client._call_api: we wrapped the originalclient._call_apiusingmock.patch.objectwithwraps=client._call_api. This lets the real_call_api(including theretrydecorator) execute, but we can still inspect the calls.retryargument: we added a loop throughwrapped_call_api.mock_callsto check theretryobject passed as the first argument to_call_api.called_retryobject match theexpected_retry(which is eitherDEFAULT_RETRYor the "custom retry" object). we've included a specific check for the_timeout == 10.0in the "custom retry" case.job.state,result.output_rows, andconn.api_request.call_countare still in place.