diff options
| author | Chuck Short <chuck.short@canonical.com> | 2013-08-14 07:51:53 -0400 |
|---|---|---|
| committer | Chuck Short <chuck.short@canonical.com> | 2013-08-14 07:53:20 -0400 |
| commit | eaec23b7ca0f4f52aec643db158c22f0af0d70c1 (patch) | |
| tree | 891279de1ae45b76e763f104651a2275d64a02b7 | |
| parent | 2548344ec644de763a18d7f582094d2e26861887 (diff) | |
| download | oslo-eaec23b7ca0f4f52aec643db158c22f0af0d70c1.tar.gz oslo-eaec23b7ca0f4f52aec643db158c22f0af0d70c1.tar.xz oslo-eaec23b7ca0f4f52aec643db158c22f0af0d70c1.zip | |
py3kcompat: Add urljoin compatibility
Add urljoin for python2/python3 compatibility,
used by python-keystoneclient.
Change-Id: Ied0841bf6b34d0087002c77915031156767b3d8d
Signed-off-by: Chuck Short <chuck.short@canonical.com>
| -rw-r--r-- | openstack/common/py3kcompat/urlutils.py | 2 | ||||
| -rw-r--r-- | tests/unit/test_compat.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/openstack/common/py3kcompat/urlutils.py b/openstack/common/py3kcompat/urlutils.py index 95ad274..04b3418 100644 --- a/openstack/common/py3kcompat/urlutils.py +++ b/openstack/common/py3kcompat/urlutils.py @@ -27,6 +27,7 @@ if six.PY3: import urllib.parse urlencode = urllib.parse.urlencode + urljoin = urllib.parse.urljoin quote = urllib.parse.quote parse_qsl = urllib.parse.parse_qsl urlparse = urllib.parse.urlparse @@ -42,6 +43,7 @@ else: parse = urlparse parse_qsl = parse.parse_qsl + urljoin = parse.urljoin urlparse = parse.urlparse urlsplit = parse.urlsplit urlunsplit = parse.urlunsplit diff --git a/tests/unit/test_compat.py b/tests/unit/test_compat.py index 2e08f37..5c3d9e5 100644 --- a/tests/unit/test_compat.py +++ b/tests/unit/test_compat.py @@ -26,6 +26,12 @@ class CompatTestCase(utils.BaseTestCase): result = urlutils.urlencode({'Fake': fake}) self.assertEquals(result, 'Fake=fake') + def test_urljoin(self): + root_url = "http://yahoo.com/" + url2 = "faq.html" + result = urlutils.urljoin(root_url, url2) + self.assertEquals(result, "http://yahoo.com/faq.html") + def test_urlquote(self): url = "/~fake" result = urlutils.quote(url) |
