def aim_to_xhtml(s): '''Wraps AIM HTML which might have <html> and <body> with a <span>.''' s, bgcolor = _remove_html_cruft(s) if bgcolor: bgstyle = ' style="background: %s;"' % dequote(bgcolor) else: bgstyle = '' return u'<div%s>%s</div>' % (bgstyle, preserve_whitespace(s))
def test_preserve_whitespace(self): cases = [ ('', ''), ('test', 'test'), ('<b>test</b>', '<b>test</b>'), (' ', ' '), (' ', ' '), (' ', ' '), ('test abc\ndef', 'test abc<br />def'), ] for inp, expected in cases: self.expect_equal(expected, preserve_whitespace(inp))