Skip to content

Commit

Permalink
skip testcase stdlib ConnectionError on Python2
Browse files Browse the repository at this point in the history
  • Loading branch information
cojenco committed May 19, 2021
1 parent c37d6bb commit 9d7f594
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/unit/test_retry.py
Expand Up @@ -19,6 +19,14 @@
import mock


try:
ConnectionError
except NameError:
_HAS_STDLIB_CONNECTION_ERROR = False
else:
_HAS_STDLIB_CONNECTION_ERROR = True


class Test_should_retry(unittest.TestCase):
def _call_fut(self, exc):
from google.cloud.storage import retry
Expand Down Expand Up @@ -65,15 +73,12 @@ def test_miss_w_stdlib_error(self):
exc = ValueError("testing")
self.assertFalse(self._call_fut(exc))

@unittest.skipUnless(
_HAS_STDLIB_CONNECTION_ERROR, "No builtin 'ConnectionError' in Python 2",
)
def test_w_stdlib_connection_error(self):
from google.cloud.storage import retry

try:
exc = ConnectionError()
self.assertTrue(self._call_fut(exc))
self.assertTrue(ConnectionError in retry._RETRYABLE_TYPES)
except NameError:
pass
exc = ConnectionError()
self.assertTrue(self._call_fut(exc))


class TestConditionalRetryPolicy(unittest.TestCase):
Expand Down

0 comments on commit 9d7f594

Please sign in to comment.