提交 04838268 编写于 作者: H Hugo Lopes Tavares

Fix issue #366 - pip throws IndexError when it calls `scraped_rel_links`

上级 0632a783
......@@ -17,6 +17,9 @@ develop (unreleased)
restart-in-venv mechanism that's broken, and neither one is useful since
every virtualenv now has pip inside it.
* Fixed issue #366 - pip throws IndexError when it calls `scraped_rel_links`
1.0.2 (2011-07-16)
------------------
......
......@@ -549,7 +549,7 @@ class HTMLPage(object):
href_match = self._href_re.search(self.content, pos=match.end())
if not href_match:
continue
url = match.group(1) or match.group(2) or match.group(3)
url = href_match.group(1) or href_match.group(2) or href_match.group(3)
if not url:
continue
url = self.clean_link(urlparse.urljoin(self.base_url, url))
......
from pip.index import package_to_requirement
from pip.index import package_to_requirement, HTMLPage
def test_package_name_should_be_converted_to_requirement():
......@@ -8,3 +8,21 @@ def test_package_name_should_be_converted_to_requirement():
assert package_to_requirement('Foo-1.2') == 'Foo==1.2'
assert package_to_requirement('Foo-dev') == 'Foo==dev'
assert package_to_requirement('Foo') == 'Foo'
def test_html_page_should_be_able_to_scrap_rel_links():
"""
Test scraping page looking for url in href
"""
page = HTMLPage("""
<!-- The <th> elements below are a terrible terrible hack for setuptools -->
<li>
<strong>Home Page:</strong>
<!-- <th>Home Page -->
<a href="http://supervisord.org/">http://supervisord.org/</a>
</li>""", "supervisor")
links = list(page.scraped_rel_links())
assert len(links) == 1
assert links[0].url == 'http://supervisord.org/'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册