summaryrefslogtreecommitdiff
path: root/src/lxml/html/tests
diff options
context:
space:
mode:
authorscoder <none@none>2009-10-17 02:11:42 +0200
committerscoder <none@none>2009-10-17 02:11:42 +0200
commita49509f5c24e2d8a7fda8d3feff46c200b97b3da (patch)
tree1cb537c28d22ddaf7c70b8ce5bfb3756e4e3fc52 /src/lxml/html/tests
parent0878e377e3859cde852c87cda023a562a407cd95 (diff)
downloadpython-lxml-a49509f5c24e2d8a7fda8d3feff46c200b97b3da.tar.gz
[svn r4237] r5292@delle: sbehnel | 2009-10-17 02:11:33 +0200
fix bug 449926: reverse URL iteration inside of text content to simplify replacements --HG-- branch : trunk
Diffstat (limited to 'src/lxml/html/tests')
-rw-r--r--src/lxml/html/tests/test_rewritelinks.txt52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/lxml/html/tests/test_rewritelinks.txt b/src/lxml/html/tests/test_rewritelinks.txt
index 1ba2dc5f..43dd99da 100644
--- a/src/lxml/html/tests/test_rewritelinks.txt
+++ b/src/lxml/html/tests/test_rewritelinks.txt
@@ -1,3 +1,8 @@
+
+Setup::
+
+ >>> import lxml.html
+
We'll define a link translation function:
>>> base_href = 'http://old/base/path.html'
@@ -118,8 +123,8 @@ link)``, which is awkward to test here, so we'll make a printer::
... </table>
... </body></html>'''))
link href="style.css"
- style None="/bg.gif"@40
style None="/other-styles.css"@69
+ style None="/bg.gif"@40
script src="/js-funcs.js"
a href="/test.html"
a href="/other.html"
@@ -179,3 +184,48 @@ An application of ``iterlinks()`` is ``make_links_absolute()``::
</table>
</body>
</html>
+
+Check if we can replace multiple links inside of the same text string::
+
+ >>> html = lxml.html.fromstring ("""\
+ ... <html>
+ ... <head>
+ ... <title>Test</title>
+ ... <style type='text/css'>
+ ... .bg1 {
+ ... background: url(images/bg1.png);
+ ... }
+ ... .bg2 {
+ ... background: url(images/bg2.png);
+ ... }
+ ... </style>
+ ... </head>
+ ... <body>
+ ... <p>Hi</p>
+ ... </body>
+ ... </html>
+ ... """,
+ ... base_url = 'http://www.example.com/')
+
+ >>> html.make_links_absolute ()
+
+ >>> try: _unicode = unicode
+ ... except NameError: _unicode = str
+
+ >>> print(lxml.html.tostring (html, pretty_print = True, encoding=_unicode))
+ <html>
+ <head>
+ <title>Test</title>
+ <style type="text/css">
+ .bg1 {
+ background: url(http://www.example.com/images/bg1.png);
+ }
+ .bg2 {
+ background: url(http://www.example.com/images/bg2.png);
+ }
+ </style>
+ </head>
+ <body>
+ <p>Hi</p>
+ </body>
+ </html>