Skip to content

Commit

Permalink
fix: address coverage and lint issues failing presubmits
Browse files Browse the repository at this point in the history
  • Loading branch information
vchudnov-g committed Dec 12, 2023
1 parent 7cf9fbf commit 34ec401
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions google/api_core/retry/retry_streaming_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,15 @@ async def retry_target_stream(

# TODO: Remove this conditional once the minimum supported Python version is 3.11
if sys.version_info[:3] >= (3, 11, 0):
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
sys.exception()) # type: ignore
await cast(
AsyncGenerator["_Y", None], target_iterator
).athrow(
sys.exception()
) # type: ignore
else:
await cast(AsyncGenerator["_Y", None], target_iterator).athrow(
*sys.exc_info())
await cast(
AsyncGenerator["_Y", None], target_iterator
).athrow(*sys.exc_info())
else:
raise
return
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/retry/test_retry_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re

import mock
import pytest
import requests.exceptions

from google.api_core import exceptions
Expand Down Expand Up @@ -136,7 +137,8 @@ def test_constructor_options(self):
assert retry_._timeout == 4
assert retry_._on_error is _some_function

def test_with_timeout(self):
@pytest.mark.parametrize("use_deadline", [True, False])
def test_with_timeout(self, use_deadline):
retry_ = self._make_one(
predicate=mock.sentinel.predicate,
initial=1,
Expand All @@ -145,9 +147,12 @@ def test_with_timeout(self):
timeout=4,
on_error=mock.sentinel.on_error,
)
new_retry = retry_.with_timeout(42)
new_retry = (
retry_.with_timeout(42) if not use_deadline else retry_.with_deadline(42)
)
assert retry_ is not new_retry
assert new_retry._timeout == 42
assert new_retry.timeout == 42 if not use_deadline else new_retry.deadline == 42

# the rest of the attributes should remain the same
assert new_retry._predicate is retry_._predicate
Expand Down

0 comments on commit 34ec401

Please sign in to comment.