def test_append_text_2(self): txt = "TEXT TAIL" span = Span(text=txt) self.assertEqual(span.text, "TEXT ") self.assertEqual(span[0].TAG, CN('text:s')) self.assertEqual(span[0].tail, "TAIL") self.assertEqual(span.plaintext(), txt)
def atext( t): if x is ListItem and t[0] in '-*+': t = t[1:].strip() t = t.replace( '"', '"') t = t.replace( '&', '&') t = Span(t) for k,v in wraps.items(): if getattr( s, k, False): assert not t.style_name t.style_name = v last.append( t)
def test_append_text_3(self): txt = "TEXT TAIL \n \t " span = Span(text=txt) self.assertEqual(span.text, "TEXT ") self.assertEqual(span[0].TAG, CN('text:s')) self.assertEqual(span[0].tail, "TAIL ") self.assertEqual(span[1].TAG, CN('text:line-break')) self.assertEqual(span[1].tail, " ") self.assertEqual(span[2].TAG, CN('text:s')) self.assertEqual(span[2].tail, None) self.assertEqual(span[3].TAG, CN('text:tab')) self.assertEqual(span[3].tail, " ") self.assertEqual(span[4].TAG, CN('text:s')) self.assertEqual(span[4].count, 3) self.assertEqual(span.plaintext(), txt)
def test_plaintext_with_tab(self): span = Span(xmlnode=etree.XML(SPANDATA_TAB)) self.assertEqual(span.plaintext(), 'Line1\tLine2')
def test_plaintext_with_spaces(self): span = Span(xmlnode=etree.XML(SPANDATA_SPC)) self.assertEqual(span.plaintext(), 'aliquyam ')
def test_append_text(self): txt = "TEXT" span = Span(text=txt) self.assertEqual(span.text, txt) self.assertEqual(span.plaintext(), txt)
def test_plaintext_with_all(self): span = Span(xmlnode=etree.XML(SPANDATA_ALL)) self.assertEqual(span.plaintext(), 'Line1\nLine2\t123 tail')
def test_plaintext_with_line_break(self): span = Span(xmlnode=etree.XML(SPANDATA_BRK)) self.assertEqual(span.plaintext(), 'Line1\nLine2')
def test_append_text_4(self): span = Span(text="TEXT") span.append_text(" TAIL") self.assertEqual(span.text, "TEXT ") self.assertEqual(span[0].TAG, CN('text:s')) self.assertEqual(span[0].tail, "TAIL")
def test_set_style_name(self): span = Span(xmlnode=etree.XML(SPANDATA)) span.style_name = "XXX" self.assertEqual(span.style_name, 'XXX')
def test_get_style_name(self): span = Span(xmlnode=etree.XML(SPANDATA)) self.assertEqual(span.style_name, 'T2')
def test_textlen_with_all(self): span = Span(xmlnode=etree.XML(SPANDATA_ALL)) self.assertEqual(span.textlen, 23)
def test_bare_init(self): span = Span() self.assertTrue(isinstance(span, GenericWrapper)) self.assertEqual(span.xmlnode.tag, CN('text:span'))
def test_init_xmlroot(self): node = etree.Element(CN('text:span'), test="span") span = Span(xmlnode=node) self.assertTrue(isinstance(span, GenericWrapper)) self.assertEqual(span.xmlnode.tag, CN('text:span')) self.assertEqual(span.xmlnode.get('test'), "span")
def test_init_XML(self): node = etree.XML(SPANDATA) span = Span(xmlnode=node) self.assertTrue(isinstance(span, GenericWrapper)) self.assertEqual(span.xmlnode.tag, CN('text:span'))
def test_textlen(self): span = Span(xmlnode=etree.XML(SPANDATA)) self.assertEqual(span.textlen, 8)
def test_textlen_with_spaces(self): span = Span(xmlnode=etree.XML(SPANDATA_SPC)) self.assertEqual(span.textlen, 12)
def test_textlen_with_line_break(self): span = Span(xmlnode=etree.XML(SPANDATA_BRK)) self.assertEqual(span.textlen, 11)
def test_textlen_with_tab(self): span = Span(xmlnode=etree.XML(SPANDATA_TAB)) self.assertEqual(span.textlen, 11)
def test_plaintext(self): span = Span(xmlnode=etree.XML(SPANDATA)) self.assertEqual(span.plaintext(), "aliquyam")