Commit 4ae4faeb authored by Jason R. Coombs's avatar Jason R. Coombs

Moved imports to the top, made them compatible with Python 2, and added a docstring.

parent a87729f8
......@@ -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,
......
"""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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment