Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Oct 30, 2023
1 parent 663fb2f commit 4675b44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion google/api_core/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def retry_target(
try:
result = target()
if inspect.isawaitable(result):
raise exceptions.GoogleAPICallError("Warning: Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead.")
raise exceptions.GoogleAPICallError(
"Warning: Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead."
)
return result

# pylint: disable=broad-except
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def test_retry_target_non_retryable_error(utcnow, sleep):
assert exc_info.value == exception
sleep.assert_not_called()


@mock.patch("asyncio.sleep", autospec=True)
@mock.patch(
"google.api_core.datetime_helpers.utcnow",
Expand All @@ -142,7 +143,9 @@ async def test_retry_target_warning_for_retry(utcnow, sleep):
with pytest.raises(exceptions.GoogleAPICallError) as exc_info:
retry.retry_target(target, predicate, range(10), None)

assert exc_info.match("Warning: Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead.")
assert exc_info.match(
"Warning: Using the synchronous google.api_core.retry.Retry with asynchronous calls may lead to unexpected results. Please use google.api_core.retry_async.AsyncRetry instead."
)
assert exc_info.type == exceptions.GoogleAPICallError
sleep.assert_not_called()

Expand Down

0 comments on commit 4675b44

Please sign in to comment.