def test_newline_to_br(self): """ newline_to_br should work identically with either DOS-style or Unix-style newlines. """ from DocumentTemplate import DT_Var text = '''\ line one line two line three ''' self.assertEqual( DT_Var.newline_to_br(text), '''\ <br /> line one<br /> line two<br /> <br /> line three<br /> ''') dos = text.replace('\n', '\r\n') self.assertEqual(DT_Var.newline_to_br(text), DT_Var.newline_to_br(dos))
def test_newline_to_br_tainted(self): from DocumentTemplate import DT_Var text = '''\ <li>line one</li> <li>line two</li> ''' from AccessControl.tainted import TaintedString tainted = TaintedString(text) self.assertEqual( DT_Var.newline_to_br(tainted), '''\ <br /> <li>line one</li><br /> <li>line two</li><br /> ''')