(url, link, expected)
| 159 | ('http://example.com/', '//xkcd.com/about/', 'http://xkcd.com/about/'), |
| 160 | ]) |
| 161 | def test_absolute_links(url, link, expected): |
| 162 | head_template = """<head><base href='{}'></head>""" |
| 163 | body_template = """<body><a href='{}'>Next</a></body>""" |
| 164 | |
| 165 | # Test without `<base>` tag (url is base) |
| 166 | html = HTML(html=body_template.format(link), url=url) |
| 167 | assert html.absolute_links.pop() == expected |
| 168 | |
| 169 | # Test with `<base>` tag (url is other) |
| 170 | html = HTML( |
| 171 | html=head_template.format(url) + body_template.format(link), |
| 172 | url='http://example.com/foobar/') |
| 173 | assert html.absolute_links.pop() == expected |
| 174 | |
| 175 | |
| 176 | @pytest.mark.render |
nothing calls this directly
no test coverage detected
searching dependent graphs…