diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 15:01:44 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 15:01:44 -0500 |
commit | b0abfb1c076baced9bf182a357dd47e9482bf065 (patch) | |
tree | 55a30c8bdd916583a818895c0b660f73815202d0 /setuptools/tests/test_packageindex.py | |
parent | c04abca662dcbffd00d928e06fbf32b9f49f8e57 (diff) | |
parent | 3c86c861ab9665df0e502f250a7471d09240e413 (diff) | |
download | external_python_setuptools-b0abfb1c076baced9bf182a357dd47e9482bf065.tar.gz external_python_setuptools-b0abfb1c076baced9bf182a357dd47e9482bf065.tar.bz2 external_python_setuptools-b0abfb1c076baced9bf182a357dd47e9482bf065.zip |
Merge Python 3 native support from distribute
--HG--
rename : tests/test_distribute_setup.py => tests/test_ez_setup.py
Diffstat (limited to 'setuptools/tests/test_packageindex.py')
-rw-r--r-- | setuptools/tests/test_packageindex.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 1060e787..92d1e2e0 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -2,12 +2,11 @@ """ import sys import unittest -import urllib2 import pkg_resources -import httplib +from setuptools.compat import urllib2, httplib, HTTPError, unicode import distutils.errors import setuptools.package_index -from server import IndexServer +from setuptools.tests.server import IndexServer class TestPackageIndex(unittest.TestCase): @@ -16,10 +15,11 @@ class TestPackageIndex(unittest.TestCase): url = 'http://127.0.0.1:0/nonesuch/test_package_index' try: v = index.open_url(url) - except Exception, v: + except Exception: + v = sys.exc_info()[1] self.assertTrue(url in str(v)) else: - self.assertTrue(isinstance(v,urllib2.HTTPError)) + self.assertTrue(isinstance(v, HTTPError)) def test_bad_url_typo(self): # issue 16 @@ -32,10 +32,11 @@ class TestPackageIndex(unittest.TestCase): url = 'url:%20https://svn.plone.org/svn/collective/inquant.contentmirror.plone/trunk' try: v = index.open_url(url) - except Exception, v: + except Exception: + v = sys.exc_info()[1] self.assertTrue(url in str(v)) else: - self.assertTrue(isinstance(v, urllib2.HTTPError)) + self.assertTrue(isinstance(v, HTTPError)) def test_bad_url_bad_status_line(self): index = setuptools.package_index.PackageIndex( @@ -43,14 +44,14 @@ class TestPackageIndex(unittest.TestCase): ) def _urlopen(*args): - import httplib raise httplib.BadStatusLine('line') index.opener = _urlopen url = 'http://example.com' try: v = index.open_url(url) - except Exception, v: + except Exception: + v = sys.exc_info()[1] self.assertTrue('line' in str(v)) else: raise AssertionError('Should have raise here!') @@ -67,7 +68,8 @@ class TestPackageIndex(unittest.TestCase): url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk' try: index.open_url(url) - except distutils.errors.DistutilsError, error: + except distutils.errors.DistutilsError: + error = sys.exc_info()[1] msg = unicode(error) assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg return |