root/livinglogic.python.xist/test/test_cssparse.py @ 2590:7b6bba35f3a0

Revision 2590:7b6bba35f3a0, 1.4 KB (checked in by Walter Doerwald <walter@…>, 13 years ago)

htmlspecials.pixel() now no longer uses colored pixels, instead color is
done via CSS. The URL for the one remaining transparent pixel can now be
specified via src (either as an XML attribute or via the converter context).

Rename attrs methods with() and without() to withnames() and withoutnames()
(for Python 2.5 compatibility).

Use elinks instead of w3m for asText() and move/rename this method to a
function ll.xist.ns.html.astext().

Try to make XIST independent from PyXML (however PyXML is still required
for parsing via expat and for dtd2xsc.py (because this requires xmlproc)).

Remove the long dperecated method withSep().

Use Py_ssize_t in the C source where appropriate.

Line 
1#! /usr/bin/env/python
2# -*- coding: iso-8859-1 -*-
3
4## Copyright 1999-2006 by LivingLogic AG, Bayreuth/Germany.
5## Copyright 1999-2006 by Walter Dörwald
6##
7## All Rights Reserved
8##
9## See xist/__init__.py for the license
10
11
12from ll import url
13from ll.xist import cssparsers
14
15
16def test_parse():
17    csshandler = cssparsers.ParseHandler()
18    s = "div {border: 0px;}"
19    assert csshandler.parseString(s) == s
20
21    s = "div {background-image: url(gurk.gif);}"
22    assert csshandler.parseString(s) == s
23
24    s = "div {background-image: url(gurk.gif);}"
25    assert csshandler.parseString(s, base="root:hurz/index.css") == \
26           "div {background-image: url(root:hurz/gurk.gif);}"
27
28
29def test_publish():
30    csshandler = cssparsers.PublishHandler()
31    s = "div {border: 0px;}"
32    assert csshandler.parseString(s) == s
33
34    s = "div {background-image: url(gurk.gif);}"
35    assert csshandler.parseString(s) == s
36
37
38    s = "div {background-image: url(root:hurz/gurk.gif);}"
39    assert csshandler.parseString(s, base="root:hurz/index.css") == \
40           "div {background-image: url(gurk.gif);}"
41
42
43def test_collect():
44    csshandler = cssparsers.CollectHandler()
45    s = """
46        div.c1 {background-image: url(root:hurz/hinz.gif);}
47        div.c1 {background-image: url(root:hurz/kunz.gif);}
48    """
49    csshandler.parseString(s)
50    assert len(csshandler.urls) == 2
51    assert csshandler.urls[0] == url.URL("root:hurz/hinz.gif")
52    assert csshandler.urls[1] == url.URL("root:hurz/kunz.gif")
Note: See TracBrowser for help on using the browser.