diff options
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-06-15 15:34:53 +0100 |
|---|---|---|
| committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-06-15 15:34:53 +0100 |
| commit | 8e657eac1ef02faedca99df319fff6b63f4a4305 (patch) | |
| tree | f3f2ed97342421c6b65c9caaab8ae5d830f04059 /setuptools/tests/test_packageindex.py | |
| parent | c04abca662dcbffd00d928e06fbf32b9f49f8e57 (diff) | |
| download | python-setuptools-git-8e657eac1ef02faedca99df319fff6b63f4a4305.tar.gz | |
Initial commit. All tests pass on 2.7, 3.2 and 3.3, though there are some atexit errors in the multiprocessing module in 2.7/3.2 (seemingly unrelated to setuptools).
--HG--
branch : single-codebase
Diffstat (limited to 'setuptools/tests/test_packageindex.py')
| -rw-r--r-- | setuptools/tests/test_packageindex.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 1060e787..c2ff0539 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,8 +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: - msg = unicode(error) + except distutils.errors.DistutilsError: + msg = unicode(sys.exc_info()[1]) assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg return raise RuntimeError("Did not raise") |
