root/livinglogic.python.xist/test/test_xist_url.py @ 4042:374af534512f

Revision 4042:374af534512f, 1.2 KB (checked in by Walter Doerwald <walter@…>, 9 years ago)

Strip trailing whitespace.

Line 
1#! /usr/bin/env/python
2# -*- coding: utf-8 -*-
3
4## Copyright 1999-2010 by LivingLogic AG, Bayreuth/Germany
5## Copyright 1999-2010 by Walter Dörwald
6##
7## All Rights Reserved
8##
9## See ll/__init__.py for the license
10
11
12from ll import url
13from ll.xist import xsc, parsers
14from ll.xist.ns import specials, html, jsp
15
16
17def test_url(recwarn):
18    # The recwarn argument silences the RequiredAttrMissingWarning
19    node = parsers.tree(b"<?url root:images/gurk.gif?>", parsers.SGMLOP(), parsers.NS(html), parsers.Instantiate())
20    assert node.bytes(base="root:about/us.html") == b"../images/gurk.gif"
21
22    node = parsers.tree(b'<img src="root:images/gurk.gif"/>', parsers.Expat(), parsers.NS(html), parsers.Instantiate())
23    assert node.bytes(base="root:about/us.html") == b'<img src="../images/gurk.gif" />'
24
25
26def test_fancyurl():
27    node = html.a("gurk", href=("http://", jsp.expression("server")))
28    assert node.bytes(base="root:about/us.html") == b'<a href="http://<%= server %>">gurk</a>'
29
30
31def test_replaceurls():
32    node = html.div("gurk", style="background-image: url(gurk.gif);")
33    node.attrs.style.replaceurls(lambda u: url.URL("http://www.example.org")/u)
34    assert str(node.attrs.style) == "background-image: url(http://www.example.org/gurk.gif)"
Note: See TracBrowser for help on using the browser.