diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-12-01 06:08:30 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-12-01 06:08:30 -0500 |
commit | 601f8ff8075a36247f17a737e3612394f26e4be7 (patch) | |
tree | 7513eabb6f58646dc9cc21886f367aa36f84e902 | |
parent | 18fc70484bcb540ae9d307733155ea6d0663b30b (diff) | |
download | python-setuptools-bitbucket-601f8ff8075a36247f17a737e3612394f26e4be7.tar.gz |
Moved imports to the top, made them compatible with Python 2, and added a docstring.
-rw-r--r-- | setuptools/compat.py | 4 | ||||
-rw-r--r-- | setuptools/tests/test_packageindex.py | 10 |
2 files changed, 8 insertions, 6 deletions
diff --git a/setuptools/compat.py b/setuptools/compat.py index bbc98d66..9a191465 100644 --- a/setuptools/compat.py +++ b/setuptools/compat.py @@ -27,7 +27,7 @@ if sys.version_info[0] < 3: unichr = unichr unicode = unicode bytes = str - from urllib import url2pathname, splittag + from urllib import url2pathname, splittag, pathname2url import urllib2 from urllib2 import urlopen, HTTPError, URLError, unquote, splituser from urlparse import urlparse, urlunparse, urljoin, urlsplit, urlunsplit @@ -73,7 +73,7 @@ else: bytes = bytes from urllib.error import HTTPError, URLError import urllib.request as urllib2 - from urllib.request import urlopen, url2pathname + from urllib.request import urlopen, url2pathname, pathname2url from urllib.parse import ( urlparse, urlunparse, unquote, splituser, urljoin, urlsplit, urlunsplit, splittag, diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 5a0c3946..664566a3 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -1,9 +1,10 @@ """Package Index Tests """ import sys +import os import unittest import pkg_resources -from setuptools.compat import urllib2, httplib, HTTPError, unicode +from setuptools.compat import urllib2, httplib, HTTPError, unicode, pathname2url import distutils.errors import setuptools.package_index from setuptools.tests.server import IndexServer @@ -152,13 +153,14 @@ class TestPackageIndex(unittest.TestCase): self.assertEqual(rev, '2995') def test_local_index(self): + """ + local_open should be able to read an index from the file system. + """ f = open('index.html', 'w') f.write('<div>content</div>') f.close() try: - import urllib.request - import os - url = 'file:' + urllib.request.pathname2url(os.getcwd()) + '/' + url = 'file:' + pathname2url(os.getcwd()) + '/' res = setuptools.package_index.local_open(url) finally: os.remove('index.html') |