diff --git a/test/test_xhtml.py b/test/test_xhtml.py index d81505da..4f0f2b4f 100644 --- a/test/test_xhtml.py +++ b/test/test_xhtml.py @@ -4,10 +4,19 @@ Test the functions in the `xhtml` module import pytest import xml - +import poezio.xhtml from poezio.xhtml import (poezio_colors_to_html, xhtml_to_poezio_colors, _parse_css as parse_css, clean_text) +class ConfigShim(object): + def __init__(self): + self.value = True + def get(self, *args, **kwargs): + return self.value + +config = ConfigShim() +poezio.xhtml.config = config + def test_clean_text(): example_string = '\x191}Toto \x192,-1}titi\x19b Tata' assert clean_text(example_string) == 'Toto titi Tata' @@ -47,10 +56,32 @@ def test_xhtml_to_poezio_colors(): with pytest.raises(xml.sax._exceptions.SAXParseException): xhtml_to_poezio_colors(b'
Invalid xml') +def test_xhtml_to_poezio_colors_disabled(): + config.value = False + start = b'
' + end = b'
' + xhtml = start + b'test' + end + assert xhtml_to_poezio_colors(xhtml) == 'test' + + xhtml = start + b'salut' + end + assert xhtml_to_poezio_colors(xhtml) == '\x19usalut\x19o (http://perdu.com)' + + xhtml = start + b'http://perdu.com' + end + assert xhtml_to_poezio_colors(xhtml) == '\x19uhttp://perdu.com\x19o' + + xhtml = b'