Add support (and fix bug) for Python 3.7

This commit is contained in:
2018-09-17 18:44:34 +02:00
parent c0f46d0562
commit 522356c4ff
5 changed files with 14 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ Version 1.7 (in development)
- Added support pickling/unpickling resources.
- Added support for `datetime` objects in API requests.
- Added support for Python 3.7
Version 1.6

View File

@@ -57,10 +57,13 @@ def join_url(url, *paths):
"""
assert isinstance(url, string_type), 'URL must be string type, not %r' % url
url_parts = [url.rstrip('/')]
for path in paths:
assert isinstance(path, string_type), 'Path components must be string type, not %r' % path
url = re.sub(r'/?$', re.sub(r'^/?', '/', path), url)
return url
url_parts.append(path.strip('/'))
if paths and paths[-1].endswith('/'):
url_parts.append('')
return '/'.join(url_parts)
def join_url_params(url, params):

View File

@@ -29,6 +29,7 @@ setup(
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Python Modules'
],
keywords=['pillar', 'rest', 'sdk', 'tracking', 'film', 'production']

View File

@@ -91,3 +91,9 @@ class PillarUtilsTests(unittest.TestCase):
self.assertFalse(utils.is_valid_id(u'55f…'))
self.assertFalse(utils.is_valid_id(u'ประเทศไทย'))
def test_join_api_me(self):
# This reproduces an issue we saw when upgrading to Python 3.7.
# It resulted in the '/users/me' part being doubled.
the_url = utils.join_url('https://cloud.blender.org/api/', '/users/me')
self.assertEqual('https://cloud.blender.org/api/users/me', the_url)

View File

@@ -1,6 +1,6 @@
[tox]
# Environment changes have to be manually synced with '.travis.yml'.
envlist = py27,py35,py36
envlist = py27,py35,py36,py37
[pytest]
;addopts = -v --cov pillarsdk --cov-report term-missing