diff --git a/.travis.yml b/.travis.yml index 9f422c6..8d17484 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,11 @@ language: python + +python: + - "2.7" + - "3.6" + - "3.7-dev" # 3.7 development branch + install: - python setup.py develop - - pip install tox -script: tox -e $TOXENV notifications: email: false -env: - - TOXENV=py27 - - TOXENV=py33 - - TOXENV=py34 - - TOXENV=nightly - - TOXENV=pypy diff --git a/bigquery/client.py b/bigquery/client.py index 17a3a89..bd4a700 100644 --- a/bigquery/client.py +++ b/bigquery/client.py @@ -15,6 +15,9 @@ from googleapiclient.errors import HttpError from httplib2 import Http +if sys.version_info >= (3, 0): + basestring = str + BIGQUERY_SCOPE = [ 'https://www.googleapis.com/auth/bigquery' ] @@ -1213,7 +1216,7 @@ def wait_for_job(self, job, interval=5, timeout=60): jobId=job_id) job_resource = request.execute() self._raise_executing_exception_if_error(job_resource) - complete = job_resource.get('status').get('state') == u'DONE' + complete = job_resource.get('status').get('state') == 'DONE' elapsed_time = time() - start_time # raise exceptions if timeout @@ -1489,7 +1492,7 @@ def _filter_tables_by_time(self, tables, start_time, end_time): Table names that are inside the time range """ - return [table_name for (table_name, unix_seconds) in tables.items() + return [table_name for (table_name, unix_seconds) in list(tables.items()) if self._in_range(start_time, end_time, unix_seconds)] def _in_range(self, start_time, end_time, time): diff --git a/bigquery/query_builder.py b/bigquery/query_builder.py index 1054299..b28c1d9 100644 --- a/bigquery/query_builder.py +++ b/bigquery/query_builder.py @@ -81,7 +81,7 @@ def _render_select(selections): return 'SELECT *' rendered_selections = [] - for name, options in selections.items(): + for name, options in list(selections.items()): if not isinstance(options, list): options = [options] diff --git a/bigquery/tests/test_client.py b/bigquery/tests/test_client.py index 1315147..bfbe800 100644 --- a/bigquery/tests/test_client.py +++ b/bigquery/tests/test_client.py @@ -655,9 +655,9 @@ def setUp(self): def test_completed_jobs(self): """Ensure we can detect completed jobs""" - return_values = [{'status': {'state': u'RUNNING'}, + return_values = [{'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}}, - {'status': {'state': u'DONE'}, + {'status': {'state': 'DONE'}, 'jobReference': {'jobId': "testJob"}}] def side_effect(*args, **kwargs): @@ -667,7 +667,7 @@ def side_effect(*args, **kwargs): job_resource = self.client.wait_for_job( {'jobReference': {'jobId': "testJob"}, - 'status': {'state': u'RUNNING'}}, + 'status': {'state': 'RUNNING'}}, interval=.01, timeout=.05) @@ -676,7 +676,7 @@ def side_effect(*args, **kwargs): def test_timeout_error(self): """Ensure that timeout raise exceptions""" - incomplete_job = {'status': {'state': u'RUNNING'}, + incomplete_job = {'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}} self.api_mock.jobs().get().execute.return_value = incomplete_job @@ -685,7 +685,7 @@ def test_timeout_error(self): def test_wait_job_http_error(self): """ Test wait job with http error""" - job = {'status': {'state': u'RUNNING'}, + job = {'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}} expected_result = { @@ -709,7 +709,7 @@ def test_wait_job_http_error(self): def test_wait_job_error_result(self): """ Test wait job with error result""" - job = {'status': {'state': u'RUNNING'}, + job = {'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}} expected_result = { @@ -733,9 +733,9 @@ def test_wait_job_error_result(self): def test_accepts_job_id(self): """Ensure it accepts a job Id rather than a full job resource""" - return_values = [{'status': {'state': u'RUNNING'}, + return_values = [{'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}}, - {'status': {'state': u'DONE'}, + {'status': {'state': 'DONE'}, 'jobReference': {'jobId': "testJob"}}] def side_effect(*args, **kwargs): @@ -751,9 +751,9 @@ def side_effect(*args, **kwargs): self.assertIsInstance(job_resource, dict) def test_accepts_integer_job_id(self): - return_values = [{'status': {'state': u'RUNNING'}, + return_values = [{'status': {'state': 'RUNNING'}, 'jobReference': {'jobId': "testJob"}}, - {'status': {'state': u'DONE'}, + {'status': {'state': 'DONE'}, 'jobReference': {'jobId': "testJob"}}] def side_effect(*args, **kwargs): @@ -784,7 +784,7 @@ def setUp(self): def test_csv_job_body_constructed_correctly(self): expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { @@ -843,7 +843,7 @@ def test_csv_job_body_constructed_correctly(self): def test_json_job_body_constructed_correctly(self): expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { @@ -938,7 +938,7 @@ def test_skip_leading_rows_exception_if_not_csv(self): def test_accepts_single_source_uri(self): """Ensure that a source_uri accepts a non-list""" expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { @@ -1033,7 +1033,7 @@ def setUp(self): def test_export(self, mock_generate_hex): """ Ensure that export is working in normal circumstances """ expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { @@ -1134,7 +1134,7 @@ def setUp(self): def test_write(self): """ Ensure that write is working in normal circumstances.""" expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { @@ -1175,7 +1175,7 @@ def test_write(self): def test_write_maxbilltier(self): """ Ensure that write is working when maximumBillingTier is set""" expected_result = { - 'status': {'state': u'RUNNING'}, + 'status': {'state': 'RUNNING'}, } body = { diff --git a/bigquery/tests/test_schema_builder.py b/bigquery/tests/test_schema_builder.py index 060162b..80023d4 100644 --- a/bigquery/tests/test_schema_builder.py +++ b/bigquery/tests/test_schema_builder.py @@ -15,7 +15,7 @@ def test_str_is_string(self): six.assertCountEqual(self, bigquery_type("Bob"), 'string') def test_unicode_is_string(self): - six.assertCountEqual(self, bigquery_type(u"Here is a happy face \u263A"), + six.assertCountEqual(self, bigquery_type("Here is a happy face \u263A"), 'string') def test_int_is_integer(self):