diff --git a/gcloud/_helpers.py b/gcloud/_helpers.py index 7b91c00271da..b60b17290180 100644 --- a/gcloud/_helpers.py +++ b/gcloud/_helpers.py @@ -304,7 +304,7 @@ def _total_seconds(offset): :returns: The total seconds (including microseconds) in the duration. """ - if sys.version_info[:2] < (2, 7): # pragma: NO COVER + if sys.version_info[:2] < (2, 7): # pragma: NO COVER Python 2.6 return _total_seconds_backport(offset) else: return offset.total_seconds() diff --git a/gcloud/bigquery/test_query.py b/gcloud/bigquery/test_query.py index bed46d9e85e3..1d762fbf0bd3 100644 --- a/gcloud/bigquery/test_query.py +++ b/gcloud/bigquery/test_query.py @@ -324,9 +324,5 @@ def api_request(self, **kw): from gcloud.exceptions import NotFound self._requested.append(kw) - try: - response, self._responses = self._responses[0], self._responses[1:] - except: # pragma: NO COVER - raise NotFound('miss') - else: - return response + response, self._responses = self._responses[0], self._responses[1:] + return response diff --git a/gcloud/bigtable/happybase/test_pool.py b/gcloud/bigtable/happybase/test_pool.py index f61658ae35fc..c3634681e45d 100644 --- a/gcloud/bigtable/happybase/test_pool.py +++ b/gcloud/bigtable/happybase/test_pool.py @@ -178,7 +178,7 @@ def test_connection_is_context_manager(self): queue_return = _Connection() pool = self._makeOneWithMockQueue(queue_return) cnxn_context = pool.connection() - if six.PY3: # pragma: NO COVER + if six.PY3: # pragma: NO COVER Python 3 self.assertTrue(isinstance(cnxn_context, contextlib._GeneratorContextManager)) else: diff --git a/gcloud/datastore/test_helpers.py b/gcloud/datastore/test_helpers.py index caa5e9cec2b1..fb18bf069b59 100644 --- a/gcloud/datastore/test_helpers.py +++ b/gcloud/datastore/test_helpers.py @@ -462,7 +462,7 @@ def test_native_str(self): name, value = self._callFUT('str') if six.PY2: self.assertEqual(name, 'blob_value') - else: # pragma: NO COVER + else: # pragma: NO COVER Python 3 self.assertEqual(name, 'string_value') self.assertEqual(value, 'str') @@ -696,7 +696,7 @@ def test_native_str(self): self._callFUT(pb, 'str') if six.PY2: value = pb.blob_value - else: # pragma: NO COVER + else: # pragma: NO COVER Python 3 value = pb.string_value self.assertEqual(value, 'str') diff --git a/gcloud/logging/test_metric.py b/gcloud/logging/test_metric.py index cbba9d1c4252..4fdbae59d297 100644 --- a/gcloud/logging/test_metric.py +++ b/gcloud/logging/test_metric.py @@ -303,7 +303,7 @@ def api_request(self, **kw): try: response, self._responses = self._responses[0], self._responses[1:] - except: # pragma: NO COVER + except: raise NotFound('miss') else: return response diff --git a/gcloud/logging/test_sink.py b/gcloud/logging/test_sink.py index 103aa0ab6b8c..8ef6c9c4559d 100644 --- a/gcloud/logging/test_sink.py +++ b/gcloud/logging/test_sink.py @@ -313,7 +313,7 @@ def api_request(self, **kw): try: response, self._responses = self._responses[0], self._responses[1:] - except: # pragma: NO COVER + except: raise NotFound('miss') else: return response diff --git a/gcloud/search/test_index.py b/gcloud/search/test_index.py index 40225d1a358d..898cadb9ab86 100644 --- a/gcloud/search/test_index.py +++ b/gcloud/search/test_index.py @@ -346,9 +346,5 @@ def api_request(self, **kw): from gcloud.exceptions import NotFound self._requested.append(kw) - try: - response, self._responses = self._responses[0], self._responses[1:] - except: # pragma: NO COVER - raise NotFound('miss') - else: - return response + response, self._responses = self._responses[0], self._responses[1:] + return response diff --git a/gcloud/storage/batch.py b/gcloud/storage/batch.py index 185df116ec35..1448b0fd9f3b 100644 --- a/gcloud/storage/batch.py +++ b/gcloud/storage/batch.py @@ -60,11 +60,11 @@ def __init__(self, method, uri, headers, body): lines.append('') lines.append(body) payload = '\r\n'.join(lines) - if six.PY2: # pragma: NO COVER Python2 - # Sigh. email.message.Message is an old-style class, so we - # cannot use 'super()'. + if six.PY2: + # email.message.Message is an old-style class, so we + # cannot use 'super()'. MIMEApplication.__init__(self, payload, 'http', encode_noop) - else: # pragma: NO COVER Python3 + else: # pragma: NO COVER Python3 super_init = super(MIMEApplicationHTTP, self).__init__ super_init(payload, 'http', encode_noop) @@ -190,9 +190,9 @@ def _prepare_batch_request(self): multi.attach(subrequest) # The `email` package expects to deal with "native" strings - if six.PY3: # pragma: NO COVER Python3 + if six.PY3: # pragma: NO COVER Python3 buf = io.StringIO() - else: # pragma: NO COVER Python2 + else: buf = io.BytesIO() generator = Generator(buf, False, 0) generator.flatten(multi) diff --git a/gcloud/storage/test_acl.py b/gcloud/storage/test_acl.py index 2fed5213bb27..bb8dbea85404 100644 --- a/gcloud/storage/test_acl.py +++ b/gcloud/storage/test_acl.py @@ -802,13 +802,8 @@ def __init__(self, *responses): def api_request(self, **kw): from gcloud.exceptions import NotFound self._requested.append(kw) - - try: - response, self._responses = self._responses[0], self._responses[1:] - except: # pragma: NO COVER - raise NotFound('miss') - else: - return response + response, self._responses = self._responses[0], self._responses[1:] + return response class _Client(object): diff --git a/gcloud/storage/test_batch.py b/gcloud/storage/test_batch.py index f50ba4fe153e..0947ba7926be 100644 --- a/gcloud/storage/test_batch.py +++ b/gcloud/storage/test_batch.py @@ -565,23 +565,10 @@ class _Connection(object): def __init__(self, **kw): self.__dict__.update(kw) - def build_api_url(self, path, **_): # pragma: NO COVER - return 'http://api.example.com%s' % path - - def _make_request(self, method, url, data=None, content_type=None, - headers=None): - if content_type is not None: # pragma: NO COVER - headers['Content-Type'] = content_type - + def _make_request(self, method, url, data=None, headers=None): return self.http.request(uri=url, method=method, headers=headers, body=data) - def api_request(self, method, path, query_params=None, - data=None, content_type=None, - api_base_url=None, api_version=None, - expect_json=True): # pragma: NO COVER - pass - class _Response(dict): diff --git a/gcloud/storage/test_bucket.py b/gcloud/storage/test_bucket.py index d7f127c44898..b22e51543a45 100644 --- a/gcloud/storage/test_bucket.py +++ b/gcloud/storage/test_bucket.py @@ -1000,10 +1000,8 @@ def __init__(self, *responses): @staticmethod def _is_bucket_path(path): - if not path.startswith('/b/'): # pragma: NO COVER - return False # Now just ensure the path only has /b/ and one more segment. - return path.count('/') == 2 + return path.startswith('/b/') and path.count('/') == 2 def api_request(self, **kw): from gcloud.exceptions import NotFound