Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing some YAGNI test fixtures and no cover pragmas. #1734

Merged
merged 1 commit into from
Apr 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gcloud/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 2 additions & 6 deletions gcloud/bigquery/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gcloud/bigtable/happybase/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions gcloud/datastore/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion gcloud/logging/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gcloud/logging/test_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions gcloud/search/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions gcloud/storage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 2 additions & 7 deletions gcloud/storage/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 1 addition & 14 deletions gcloud/storage/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
4 changes: 1 addition & 3 deletions gcloud/storage/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment was marked as spam.

This comment was marked as spam.


def api_request(self, **kw):
from gcloud.exceptions import NotFound
Expand Down