aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_packageindex.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-07-05 15:06:51 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-07-05 15:06:51 -0400
commitb49435397a5094f94678adf3549cc8941aa469b7 (patch)
treeb123bdd63482393ba1e2859364920f40a3d9f71d /setuptools/tests/test_packageindex.py
parent5b865b1b6e23379d23aa80e74adb38db8b14b6ca (diff)
downloadexternal_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.tar.gz
external_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.tar.bz2
external_python_setuptools-b49435397a5094f94678adf3549cc8941aa469b7.zip
Use six for Python 2 compatibility
--HG-- branch : feature/issue-229 extra : source : 7b1997ececc5772798ce33a0f8e77387cb55a977
Diffstat (limited to 'setuptools/tests/test_packageindex.py')
-rw-r--r--setuptools/tests/test_packageindex.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
index 664566a3..40ae0af3 100644
--- a/setuptools/tests/test_packageindex.py
+++ b/setuptools/tests/test_packageindex.py
@@ -3,9 +3,12 @@
import sys
import os
import unittest
-import pkg_resources
-from setuptools.compat import urllib2, httplib, HTTPError, unicode, pathname2url
import distutils.errors
+
+import six
+from six.moves import urllib, http_client
+
+import pkg_resources
import setuptools.package_index
from setuptools.tests.server import IndexServer
@@ -20,7 +23,7 @@ class TestPackageIndex(unittest.TestCase):
v = sys.exc_info()[1]
self.assertTrue(url in str(v))
else:
- self.assertTrue(isinstance(v, HTTPError))
+ self.assertTrue(isinstance(v, urllib.error.HTTPError))
def test_bad_url_typo(self):
# issue 16
@@ -37,7 +40,7 @@ class TestPackageIndex(unittest.TestCase):
v = sys.exc_info()[1]
self.assertTrue(url in str(v))
else:
- self.assertTrue(isinstance(v, HTTPError))
+ self.assertTrue(isinstance(v, urllib.error.HTTPError))
def test_bad_url_bad_status_line(self):
index = setuptools.package_index.PackageIndex(
@@ -45,7 +48,7 @@ class TestPackageIndex(unittest.TestCase):
)
def _urlopen(*args):
- raise httplib.BadStatusLine('line')
+ raise http_client.BadStatusLine('line')
index.opener = _urlopen
url = 'http://example.com'
@@ -71,7 +74,7 @@ class TestPackageIndex(unittest.TestCase):
index.open_url(url)
except distutils.errors.DistutilsError:
error = sys.exc_info()[1]
- msg = unicode(error)
+ msg = six.text_type(error)
assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg
return
raise RuntimeError("Did not raise")
@@ -160,7 +163,7 @@ class TestPackageIndex(unittest.TestCase):
f.write('<div>content</div>')
f.close()
try:
- url = 'file:' + pathname2url(os.getcwd()) + '/'
+ url = 'file:' + urllib.request.pathname2url(os.getcwd()) + '/'
res = setuptools.package_index.local_open(url)
finally:
os.remove('index.html')