summaryrefslogtreecommitdiff
path: root/test/test_xhtml.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-12-08 17:01:44 +0100
committermathieui <mathieui@mathieui.net>2014-12-08 17:01:44 +0100
commite273a32ec727700d592723c4e5905510c71ed632 (patch)
tree47b04cad0ca7dfb7a79166140eca040fd8ee2870 /test/test_xhtml.py
parent4b8749ca88ef5a7e525231893b813eb0d4b2f8c1 (diff)
downloadpoezio-e273a32ec727700d592723c4e5905510c71ed632.tar.gz
poezio-e273a32ec727700d592723c4e5905510c71ed632.tar.bz2
poezio-e273a32ec727700d592723c4e5905510c71ed632.tar.xz
poezio-e273a32ec727700d592723c4e5905510c71ed632.zip
Improve the xhtml_to_poezio_colors sanitization
add some tests, and remove the test_datetime_tuple because of python time module misbehavior with timezones set manually. (potentially due to http://bugs.python.org/issue6478)
Diffstat (limited to 'test/test_xhtml.py')
-rw-r--r--test/test_xhtml.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test_xhtml.py b/test/test_xhtml.py
index 58857d67..5afd08ff 100644
--- a/test/test_xhtml.py
+++ b/test/test_xhtml.py
@@ -38,6 +38,14 @@ def test_xhtml_to_poezio_colors():
xhtml = start + b'<a href="http://perdu.com">http://perdu.com</a>' + end
assert xhtml_to_poezio_colors(xhtml) == '\x19uhttp://perdu.com\x19o'
+ xhtml = b'<div style="font-weight:bold">Allo <div style="color:red">test <div style="color: blue">test2</div></div></div>'
+ assert xhtml_to_poezio_colors(xhtml, force=True) == '\x19bAllo \x19196}test \x1921}test2\x19o'
+
+ xhtml = (b'<div style="color:blue"><div style="color:yellow">'
+ b'<div style="color:blue">Allo <div style="color:red">'
+ b'test <div style="color: blue">test2</div></div></div></div></div>')
+ assert xhtml_to_poezio_colors(xhtml, force=True) == '\x1921}Allo \x19196}test \x1921}test2\x19o'
+
with pytest.raises(xml.sax._exceptions.SAXParseException):
xhtml_to_poezio_colors(b'<p>Invalid xml')