Merge "Fix swiftclient.client.quote() for Python 3"
This commit is contained in:
		| @@ -97,8 +97,11 @@ def http_log(args, kwargs, resp, body): | ||||
|  | ||||
| def quote(value, safe='/'): | ||||
|     """ | ||||
|     Patched version of urllib.quote that encodes utf8 strings before quoting | ||||
|     Patched version of urllib.quote that encodes utf8 strings before quoting. | ||||
|     On Python 3, call directly urllib.parse.quote(). | ||||
|     """ | ||||
|     if six.PY3: | ||||
|         return _quote(value, safe=safe) | ||||
|     value = encode_utf8(value) | ||||
|     if isinstance(value, bytes): | ||||
|         return _quote(value, safe) | ||||
|   | ||||
| @@ -187,10 +187,14 @@ class MockHttpResponse(): | ||||
| class TestHttpHelpers(MockHttpTest): | ||||
|  | ||||
|     def test_quote(self): | ||||
|         value = 'standard string' | ||||
|         self.assertEqual(b'standard%20string', c.quote(value)) | ||||
|         value = u'\u0075nicode string' | ||||
|         self.assertEqual(b'unicode%20string', c.quote(value)) | ||||
|         value = b'bytes\xff' | ||||
|         self.assertEqual('bytes%FF', c.quote(value)) | ||||
|         value = 'native string' | ||||
|         self.assertEqual('native%20string', c.quote(value)) | ||||
|         value = u'unicode string' | ||||
|         self.assertEqual('unicode%20string', c.quote(value)) | ||||
|         value = u'unicode:\xe9\u20ac' | ||||
|         self.assertEqual('unicode%3A%C3%A9%E2%82%AC', c.quote(value)) | ||||
|  | ||||
|     def test_http_connection(self): | ||||
|         url = 'http://www.test.com' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jenkins
					Jenkins