Skip to content

Commit 4675b44

Browse files
1 parent 663fb2f commit 4675b44

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

‎google/api_core/retry.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ def retry_target(
204204
try:
205205
result = target()
206206
if inspect.isawaitable(result):
207-
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.")
207+
raise exceptions.GoogleAPICallError(
208+
"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."
209+
)
208210
return result
209211

210212
# pylint: disable=broad-except

‎tests/unit/test_retry.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def test_retry_target_non_retryable_error(utcnow, sleep):
128128
assert exc_info.value == exception
129129
sleep.assert_not_called()
130130

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

145-
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.")
146+
assert exc_info.match(
147+
"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."
148+
)
146149
assert exc_info.type == exceptions.GoogleAPICallError
147150
sleep.assert_not_called()
148151

0 commit comments

Comments
 (0)