modernize tests
diff --git a/tests/__init__.py b/tests/__init__.py
index 7913e6f..c4022b7 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -11,6 +11,7 @@
# limitations under the License.
"""Test Package set up."""
+from __future__ import absolute_import
__author__ = 'afshar@google.com (Ali Afshar)'
diff --git a/tests/test_channel.py b/tests/test_channel.py
index 0e348a5..2651fcd 100644
--- a/tests/test_channel.py
+++ b/tests/test_channel.py
@@ -1,4 +1,5 @@
"""Notification channels tests."""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index c16f470..b8cc959 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -20,6 +20,8 @@
Unit tests for objects created from discovery documents.
"""
+from __future__ import absolute_import
+import six
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -89,9 +91,9 @@
testcase.assertEqual(expected.fragment, actual.fragment)
expected_query = parse_qs(expected.query)
actual_query = parse_qs(actual.query)
- for name in expected_query.keys():
+ for name in list(expected_query.keys()):
testcase.assertEqual(expected_query[name], actual_query[name])
- for name in actual_query.keys():
+ for name in list(actual_query.keys()):
testcase.assertEqual(expected_query[name], actual_query[name])
@@ -133,7 +135,7 @@
self.assertEqual(STACK_QUERY_PARAMETER_DEFAULT_VALUE,
parameters[param_name])
- for param_name, value in root_desc.get('parameters', {}).iteritems():
+ for param_name, value in six.iteritems(root_desc.get('parameters', {})):
self.assertEqual(value, parameters[param_name])
return parameters
@@ -300,7 +302,7 @@
'o': 'object',
'q': 'string',
'rr': 'string'}
- keys = param_types.keys()
+ keys = list(param_types.keys())
self.assertEqual(parameters.argmap, dict((key, key) for key in keys))
self.assertEqual(parameters.required_params, [])
self.assertEqual(sorted(parameters.repeated_params), ['er', 'rr'])
@@ -318,7 +320,7 @@
parameters = ResourceMethodParameters(method_desc)
param_types = {'name': 'string'}
- keys = param_types.keys()
+ keys = list(param_types.keys())
self.assertEqual(parameters.argmap, dict((key, key) for key in keys))
self.assertEqual(parameters.required_params, ['name'])
self.assertEqual(parameters.repeated_params, [])
diff --git a/tests/test_errors.py b/tests/test_errors.py
index efb4afd..0cef892 100644
--- a/tests/test_errors.py
+++ b/tests/test_errors.py
@@ -16,6 +16,7 @@
"""Tests for errors handling
"""
+from __future__ import absolute_import
__author__ = 'afshar@google.com (Ali Afshar)'
diff --git a/tests/test_http.py b/tests/test_http.py
index 8989409..c0ec5f9 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -18,6 +18,8 @@
Unit tests for the googleapiclient.http.
"""
+from __future__ import absolute_import
+from six.moves import range
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -624,7 +626,7 @@
request.execute(num_retries=num_retries)
self.assertEqual(num_retries, len(sleeptimes))
- for retry_num in xrange(num_retries):
+ for retry_num in range(num_retries):
self.assertEqual(10 * 2**(retry_num + 1), sleeptimes[retry_num])
def test_no_retry_fails_fast(self):
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index af9841a..fec7191 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -18,6 +18,8 @@
Unit tests for the JSON model.
"""
+from __future__ import absolute_import
+import six
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -214,7 +216,7 @@
def __init__(self, items):
super(MockResponse, self).__init__()
self.status = items['status']
- for key, value in items.iteritems():
+ for key, value in six.iteritems(items):
self[key] = value
old_logging = googleapiclient.model.logging
googleapiclient.model.logging = MockLogging()
diff --git a/tests/test_mocks.py b/tests/test_mocks.py
index e3c550f..34cc8a9 100644
--- a/tests/test_mocks.py
+++ b/tests/test_mocks.py
@@ -18,6 +18,7 @@
Unit tests for the Mocks.
"""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
diff --git a/tests/test_model.py b/tests/test_model.py
index 9f29db9..1d48194 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -19,6 +19,7 @@
Unit tests for model utility methods.
"""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
diff --git a/tests/test_protobuf_model.py b/tests/test_protobuf_model.py
index fe3abc7..b765943 100644
--- a/tests/test_protobuf_model.py
+++ b/tests/test_protobuf_model.py
@@ -18,6 +18,7 @@
Unit tests for the Protocol Buffer model.
"""
+from __future__ import absolute_import
__author__ = 'mmcdonald@google.com (Matt McDonald)'
diff --git a/tests/test_schema.py b/tests/test_schema.py
index 476575c..eb41adf 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -13,6 +13,7 @@
# limitations under the License.
"""Unit tests for googleapiclient.schema."""
+from __future__ import absolute_import
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
@@ -48,7 +49,7 @@
class SchemasTest(unittest.TestCase):
def setUp(self):
- f = file(datafile('zoo.json'))
+ f = open(datafile('zoo.json'))
discovery = f.read()
f.close()
discovery = json.loads(discovery)