diff --git a/.travis.yml b/.travis.yml index 257f7dd..5410544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: python python: - "2.7" + - "3.4" install: - pip install -e . - pip install coveralls diff --git a/CHANGES.rst b/CHANGES.rst index 26cdf24..12614eb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,7 @@ ChangeLog 0.3.2 (unreleased) ------------------ -* No entry. +* Add python 3.4 support. 0.3.1 (2014-12-19) ------------------ diff --git a/ocs_sdk/apis/api_account.py b/ocs_sdk/apis/api_account.py index e9712b4..5c160d2 100644 --- a/ocs_sdk/apis/api_account.py +++ b/ocs_sdk/apis/api_account.py @@ -9,8 +9,7 @@ # file except in compliance with the License. You may obtain a copy of the # License at http://opensource.org/licenses/BSD-2-Clause -from itertools import izip_longest - +from six.moves import zip_longest import slumber from . import API @@ -63,8 +62,8 @@ def perm_matches(self, request_perm, effective_perm): effective_perm_parts = effective_perm.split(':') for (request_perm_part, - effective_perm_part) in izip_longest(request_perm_parts, - effective_perm_parts): + effective_perm_part) in zip_longest(request_perm_parts, + effective_perm_parts): if ( request_perm_part != effective_perm_part and diff --git a/ocs_sdk/tests/apis/__init__.py b/ocs_sdk/tests/apis/__init__.py index 7e889e5..51aed8c 100644 --- a/ocs_sdk/tests/apis/__init__.py +++ b/ocs_sdk/tests/apis/__init__.py @@ -9,9 +9,9 @@ # License at http://opensource.org/licenses/BSD-2-Clause import json -import urlparse import httpretty +from six.moves.urllib.parse import urljoin class FakeAPITestCase(object): @@ -31,7 +31,7 @@ def fake_endpoint(self, api, endpoint, method=httpretty.GET, httpretty.register_uri( method, - urlparse.urljoin(api.get_api_url(), endpoint), + urljoin(api.get_api_url(), endpoint), body=body, content_type='application/json', status=status diff --git a/ocs_sdk/tests/apis/test_api.py b/ocs_sdk/tests/apis/test_api.py index 21f3af8..8af1f52 100644 --- a/ocs_sdk/tests/apis/test_api.py +++ b/ocs_sdk/tests/apis/test_api.py @@ -31,7 +31,7 @@ def test_make_requests_session(self): ).make_requests_session() self.assertEqual(requests_session.headers.get('X-Auth-Token'), - '0xdeadbeef') + b'0xdeadbeef') self.assertEqual(requests_session.headers.get('User-Agent'), 'jamesb0nd') diff --git a/ocs_sdk/tests/apis/test_api_metadata.py b/ocs_sdk/tests/apis/test_api_metadata.py index 63eb542..ee438e1 100644 --- a/ocs_sdk/tests/apis/test_api_metadata.py +++ b/ocs_sdk/tests/apis/test_api_metadata.py @@ -9,9 +9,11 @@ import json import unittest -import urlparse import uuid +import six +from six.moves.urllib.parse import parse_qs, urlparse + from ocs_sdk.apis import MetadataAPI from . import FakeAPITestCase @@ -45,7 +47,7 @@ def fake_route_conf(_, uri, headers): If no format is given, return a text/plain response with a "shell" format. """ - querystring = urlparse.parse_qs(urlparse.urlparse(uri).query) + querystring = parse_qs(urlparse(uri).query) if 'json' in querystring.get('format', []): return 200, headers, json.dumps(json_response) @@ -64,5 +66,7 @@ def test_get(self): self.assertEqual(self.api.get_metadata(), expected_response) shell_response = self.api.get_metadata(as_shell=True) + if not isinstance(shell_response, str): # py3 branch + shell_response = str(shell_response, 'utf-8') self.assertIn('id="%(id)s"' % expected_response, shell_response) self.assertIn('name="%(name)s"' % expected_response, shell_response) diff --git a/setup.py b/setup.py index 5c2028a..88cca4d 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,8 @@ def get_long_description(): license='BSD', install_requires=[ - 'slumber >= 0.6.0', + 'slumber >= 0.6.2', + 'six', ], packages=find_packages(), @@ -67,6 +68,8 @@ def get_long_description(): 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Internet', 'Topic :: System :: Distributed Computing',