def test_long_string_non_ascii(self): self.assertEqual( StringValue('line1\n' 'line2\n' 'line3 \xff\n' 'line4\n' 'line5\n').render(), '\'<span class="struct">line1<br />' 'line2<br />' 'line3 \\xff<br />' 'line4<br />' 'line5\'</span>')
def test_long_string_unicode(self): self.assertEqual( StringValue(u'line1\n' u'line2\n' u'line3 \xff\n' u'line4\n' u'line5\n').render(), self.u + u'\'<span class="struct">line1<br />' u'line2<br />' u'line3 \xff<br />' u'line4<br />' u'line5\'</span>')
def test_long_string(self): self.assertEqual( StringValue('line1 <\n' 'line2 &\n' 'line3\n' 'line4\n' 'line5\n').render(), '\'<span class="struct">line1 <<br />' 'line2 &<br />' 'line3<br />' 'line4<br />' 'line5\'</span>')
def test_long_string_indentation(self): self.assertEqual( StringValue('line1\n' ' line2\n' ' line3\n' '\tline4\n' 'line5\n').render(), '\'<span class="struct">line1<br />' ' line2<br />' ' line3<br />' ' line4<br />' 'line5\'</span>')
def test_long_string_truncation(self): self.assertEqual( StringValue('line1\n' 'line2\n' 'line3\n' 'line4\n' 'line5\n' 'line6\n' 'line7').render(limit=10), '\'<span class="struct">line1<br />' 'line2<br />' 'line3<br />' 'line4<br />' 'line5<br />' '<span id="tr1" class="truncated">...</span>\'</span>') self.assertEqual(TRUNCATIONS['tr1'], "line6<br />line7")
def test_short_string_unicode(self): self.assertEqual(StringValue(u'\u1234').render(), self.u + "'\u1234'")
def test_short_string_truncation(self): self.assertEqual( StringValue('a very long string').render(limit=10), """'a very lo<span id="tr1" class="truncated">...</span>""") self.assertEqual(TRUNCATIONS['tr1'], "ng string'") self.assertEqual(list(TRUNCATIONS_IN_ORDER), ['tr1'])
def test_short_string_control_char(self): self.assertEqual(StringValue('\x17').render(), """'\\x17'""")
def test_short_string_escaping(self): self.assertEqual( StringValue('x"y\'z\\z<y&').render(), """'x"y\\'z\\\\z<y&'""")
def test_short_string(self): self.assertEqual(StringValue('xyzzy').render(), "'xyzzy'")
def test_empty_string(self): self.assertEqual(StringValue('').render(), "''")
def test_interface_compliance(self): verifyObject(IValueRenderer, StringValue(()))