Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 def test_plaintext_with_tab(self):
     span = Span(xmlnode=etree.XML(SPANDATA_TAB))
     self.assertEqual(span.plaintext(), 'Line1\tLine2')
Пример #7
0
 def test_plaintext_with_spaces(self):
     span = Span(xmlnode=etree.XML(SPANDATA_SPC))
     self.assertEqual(span.plaintext(), 'aliquyam    ')
Пример #8
0
 def test_append_text(self):
     txt = "TEXT"
     span = Span(text=txt)
     self.assertEqual(span.text, txt)
     self.assertEqual(span.plaintext(), txt)
Пример #9
0
 def test_plaintext_with_all(self):
     span = Span(xmlnode=etree.XML(SPANDATA_ALL))
     self.assertEqual(span.plaintext(), 'Line1\nLine2\t123    tail')
Пример #10
0
 def test_plaintext_with_line_break(self):
     span = Span(xmlnode=etree.XML(SPANDATA_BRK))
     self.assertEqual(span.plaintext(), 'Line1\nLine2')
Пример #11
0
 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")
Пример #12
0
 def test_append_text(self):
     txt = "TEXT"
     span = Span(text=txt)
     self.assertEqual(span.text, txt)
     self.assertEqual(span.plaintext(), txt)
Пример #13
0
 def test_set_style_name(self):
     span = Span(xmlnode=etree.XML(SPANDATA))
     span.style_name = "XXX"
     self.assertEqual(span.style_name, 'XXX')
Пример #14
0
 def test_get_style_name(self):
     span = Span(xmlnode=etree.XML(SPANDATA))
     self.assertEqual(span.style_name, 'T2')
Пример #15
0
 def test_textlen_with_all(self):
     span = Span(xmlnode=etree.XML(SPANDATA_ALL))
     self.assertEqual(span.textlen, 23)
Пример #16
0
 def test_plaintext_with_spaces(self):
     span = Span(xmlnode=etree.XML(SPANDATA_SPC))
     self.assertEqual(span.plaintext(), 'aliquyam    ')
Пример #17
0
 def test_bare_init(self):
     span = Span()
     self.assertTrue(isinstance(span, GenericWrapper))
     self.assertEqual(span.xmlnode.tag, CN('text:span'))
Пример #18
0
 def test_plaintext_with_tab(self):
     span = Span(xmlnode=etree.XML(SPANDATA_TAB))
     self.assertEqual(span.plaintext(), 'Line1\tLine2')
Пример #19
0
 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")
Пример #20
0
 def test_set_style_name(self):
     span = Span(xmlnode=etree.XML(SPANDATA))
     span.style_name = "XXX"
     self.assertEqual(span.style_name, 'XXX')
Пример #21
0
 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'))
Пример #22
0
 def test_textlen(self):
     span = Span(xmlnode=etree.XML(SPANDATA))
     self.assertEqual(span.textlen, 8)
Пример #23
0
 def test_textlen_with_spaces(self):
     span = Span(xmlnode=etree.XML(SPANDATA_SPC))
     self.assertEqual(span.textlen, 12)
Пример #24
0
 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")
Пример #25
0
 def test_textlen_with_line_break(self):
     span = Span(xmlnode=etree.XML(SPANDATA_BRK))
     self.assertEqual(span.textlen, 11)
Пример #26
0
 def test_plaintext_with_line_break(self):
     span = Span(xmlnode=etree.XML(SPANDATA_BRK))
     self.assertEqual(span.plaintext(), 'Line1\nLine2')
Пример #27
0
 def test_textlen_with_tab(self):
     span = Span(xmlnode=etree.XML(SPANDATA_TAB))
     self.assertEqual(span.textlen, 11)
Пример #28
0
 def test_plaintext_with_all(self):
     span = Span(xmlnode=etree.XML(SPANDATA_ALL))
     self.assertEqual(span.plaintext(), 'Line1\nLine2\t123    tail')
Пример #29
0
 def test_plaintext(self):
     span = Span(xmlnode=etree.XML(SPANDATA))
     self.assertEqual(span.plaintext(), "aliquyam")