def modify_message(msgobj): msg = getattr(msgobj, 'message', None) if msg is not None: # will fixup bad HTML like aim's <HTML><BODY> stuff msgobj.message = to_xhtml(msg) return msgobj
def test_html_and_body_tag_removed(self): 'test AIM-style html junk removal' # tuples of (input, expected_output) fragments = [ (u'<html><body bgcolor="#ff0000"><b>red <i>text</i></b></body></html>', u'<span style="background-color: #ff0000;"><b>red <i>text</i></b></span>' ), (u'<html><body>test</body></html>', u'test'), (u'<html>bare html</html>', u'bare html'), ] for original, expected in fragments: transformed = to_xhtml(original) self.expect_equal(expected, transformed)
def test_html_and_body_tag_removed(self): 'test AIM-style html junk removal' # tuples of (input, expected_output) fragments = [ (u'<html><body bgcolor="#ff0000"><b>red <i>text</i></b></body></html>', u'<span style="background-color: #ff0000;"><b>red <i>text</i></b></span>'), (u'<html><body>test</body></html>', u'test'), (u'<html>bare html</html>', u'bare html'), ] for original, expected in fragments: transformed = to_xhtml(original) self.expect_equal(expected, transformed)
def test_html_unharmed(self): 'test that some text fragments remain untransformed' # these shouldn't change fragments = [ '<b>test</b>', '<i>test</i>', 'test', ' ', '', 'test & test', ] for fragment in fragments: transformed = to_xhtml(fragment) self.expect_equal(fragment, transformed)