From: David Kemp (Work) Date: Wed, 25 Jan 2012 16:21:07 +0000 (+0000) Subject: fix problem with path being double escaped X-Git-Tag: v0.10.2~42^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80eafe3b63389539a201e6d26505ad91c2428fcc;p=services%2Fpython-requests.git fix problem with path being double escaped --- diff --git a/requests/models.py b/requests/models.py index 82c7572..c2cbe97 100644 --- a/requests/models.py +++ b/requests/models.py @@ -351,8 +351,8 @@ class Request(object): if not path: path = '/' - # if is_py3: - path = quote(path.encode('utf-8')) + if is_py3: + path = quote(path.encode('utf-8')) url.append(path) diff --git a/test_requests.py b/test_requests.py index 034f469..c3f3deb 100644 --- a/test_requests.py +++ b/test_requests.py @@ -72,6 +72,12 @@ class RequestsTestSuite(TestSetup, unittest.TestCase): def test_invalid_url(self): self.assertRaises(ValueError, get, 'hiwpefhipowhefopw') + + def test_path_is_not_double_encoded(self): + request = requests.Request("http://0.0.0.0/get/~test") + + assert request.path_url == "/get/%7Etest" + def test_HTTP_200_OK_GET(self): r = get(httpbin('/get')) self.assertEqual(r.status_code, 200)