Skip to content

Commit

Permalink
Adapt to new Python 3.7 urlquote behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Aug 29, 2018
1 parent c3198a0 commit e0a4631
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion libcloud/test/__init__.py
Expand Up @@ -173,7 +173,12 @@ def _example_fail(self, method, url, body, headers):

def _get_method_name(self, type, use_param, qs, path):
path = path.split('?')[0]
meth_name = path.replace('/', '_').replace('.', '_').replace('-', '_')
meth_name = (
path
.replace('/', '_')
.replace('.', '_')
.replace('-', '_')
.replace('~', '%7E')) # Python 3.7 no longer quotes ~

if type:
meth_name = '%s_%s' % (meth_name, self.type)
Expand Down
8 changes: 4 additions & 4 deletions libcloud/test/test_utils.py
Expand Up @@ -258,12 +258,12 @@ def test_unicode_urlquote(self):
self.assertEqual(b(uri), b('%C3%A9'))

# Unicode without unicode characters
uri = urlquote('~abc')
self.assertEqual(b(uri), b('%7Eabc'))
uri = urlquote('v=1')
self.assertEqual(b(uri), b('v%3D1'))

# Already-encoded bytestring without unicode characters
uri = urlquote(b('~abc'))
self.assertEqual(b(uri), b('%7Eabc'))
uri = urlquote(b('v=1'))
self.assertEqual(b(uri), b('v%3D1'))

def test_get_secure_random_string(self):
for i in range(1, 500):
Expand Down

0 comments on commit e0a4631

Please sign in to comment.