示例#1
0
 def test_iter_links__yanked_reason(self, anchor_html, expected):
     html = (
         # Mark this as a unicode string for Python 2 since anchor_html
         # can contain non-ascii.
         u'<html><head><meta charset="utf-8"><head>'
         '<body>{}</body></html>').format(anchor_html)
     html_bytes = html.encode('utf-8')
     page = HTMLPage(html_bytes, url='https://example.com/simple/')
     links = list(page.iter_links())
     link, = links
     actual = link.yanked_reason
     assert actual == expected
示例#2
0
def make_fake_html_page(url):
    html = dedent(u"""\
    <html><head><meta name="api-version" value="2" /></head>
    <body>
    <a href="/abc-1.0.tar.gz#md5=000000000">abc-1.0.tar.gz</a>
    </body></html>
    """)
    content = html.encode('utf-8')
    headers = {}
    return HTMLPage(content, url=url, headers=headers)