Commit 1e64c9a5 authored by Jason R. Coombs's avatar Jason R. Coombs

Split one test 'bad urls' into several different tests (for clarity).

--HG--
branch : distribute
extra : rebase_source : cdc7ce4fe999eb578df356ec6a2d44b65312d7d9
parent 347b49d5
"""Package Index Tests
"""
# More would be better!
import sys
import os, shutil, tempfile, unittest, urllib2
import unittest
import urllib2
import pkg_resources
import setuptools.package_index
from server import IndexServer
class TestPackageIndex(unittest.TestCase):
def test_bad_urls(self):
def test_bad_url_bad_port(self):
index = setuptools.package_index.PackageIndex()
url = 'http://127.0.0.1:0/nonesuch/test_package_index'
try:
......@@ -19,6 +19,7 @@ class TestPackageIndex(unittest.TestCase):
else:
self.assert_(isinstance(v,urllib2.HTTPError))
def test_bad_url_typo(self):
# issue 16
# easy_install inquant.contentmirror.plone breaks because of a typo
# in its home URL
......@@ -34,6 +35,11 @@ class TestPackageIndex(unittest.TestCase):
else:
self.assert_(isinstance(v, urllib2.HTTPError))
def test_bad_url_bad_status_line(self):
index = setuptools.package_index.PackageIndex(
hosts=('www.example.com',)
)
def _urlopen(*args):
import httplib
raise httplib.BadStatusLine('line')
......@@ -51,6 +57,11 @@ class TestPackageIndex(unittest.TestCase):
finally:
urllib2.urlopen = old_urlopen
def test_bad_url_double_scheme(self):
index = setuptools.package_index.PackageIndex(
hosts=('www.example.com',)
)
# issue 20
url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk'
try:
......@@ -58,6 +69,10 @@ class TestPackageIndex(unittest.TestCase):
except Exception, v:
self.assert_('nonnumeric port' in str(v))
def test_bad_url_screwy_href(self):
index = setuptools.package_index.PackageIndex(
hosts=('www.example.com',)
)
# issue #160
if sys.version_info[0] == 2 and sys.version_info[1] == 7:
......@@ -67,7 +82,6 @@ class TestPackageIndex(unittest.TestCase):
'http://www.famfamfam.com/">')
index.process_index(url, page)
def test_url_ok(self):
index = setuptools.package_index.PackageIndex(
hosts=('www.example.com',)
......
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