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))
Exemple #2
0
    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 />
&lt;li&gt;line one&lt;/li&gt;<br />
&lt;li&gt;line two&lt;/li&gt;<br />
''')
    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 />
&lt;li&gt;line one&lt;/li&gt;<br />
&lt;li&gt;line two&lt;/li&gt;<br />
''')