Ejemplo n.º 1
0
 def test_comment_data_unb(self):
     comment  = tree.comment(u'Begin spam')
     self.assertEqual(comment.xml_value, u'Begin spam')
     self.assertEqual(len(comment.xml_value), 10)
     self.assertEqual(comment.xml_value[:5], u'Begin')
     comment.xml_value += u' more spam'
     self.assertEqual(comment.xml_value, u'Begin spam more spam')
Ejemplo n.º 2
0
 def test_comment_data_unb(self):
     comment = tree.comment(u'Begin spam')
     self.assertEqual(comment.xml_value, u'Begin spam')
     self.assertEqual(len(comment.xml_value), 10)
     self.assertEqual(comment.xml_value[:5], u'Begin')
     comment.xml_value += u' more spam'
     self.assertEqual(comment.xml_value, u'Begin spam more spam')
Ejemplo n.º 3
0
 def test_create_new_doc_comment(self):
     EXPECTED = '<A a="b">One</A><!--This is easy-->'
     doc = tree.entity()
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     self.compare_output(doc, XMLDECL+EXPECTED)
     return 
Ejemplo n.º 4
0
 def test_create_new_doc_comment(self):
     EXPECTED = '<A a="b">One</A><!--This is easy-->'
     doc = tree.entity()
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     self.compare_output(doc, XMLDECL + EXPECTED)
     return
Ejemplo n.º 5
0
 def test_create_new_doc_attr_dict(self):
     EXPECTED = '<?xml-stylesheet href="classic.xsl" type="text/xml"?><A a="b">One</A><!--This is easy-->'
     doc = tree.entity()
     doc.xml_append(tree.processing_instruction(u'xml-stylesheet', 
                                                u'href="classic.xsl" type="text/xml"'))
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     self.compare_output(doc, XMLDECL+EXPECTED)
     return 
Ejemplo n.º 6
0
 def test_create_new_doc_attr_dict(self):
     EXPECTED = '<?xml-stylesheet href="classic.xsl" type="text/xml"?><A a="b">One</A><!--This is easy-->'
     doc = tree.entity()
     doc.xml_append(
         tree.processing_instruction(u'xml-stylesheet',
                                     u'href="classic.xsl" type="text/xml"'))
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     self.compare_output(doc, XMLDECL + EXPECTED)
     return
Ejemplo n.º 7
0
 def test_reading_building(self):
     doc = tree.entity()
     doc.xml_append(tree.processing_instruction(u'xml-stylesheet', 
                                                u'href="classic.xsl" type="text/xml"'))
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     doc2 = amara.parse('docs/whatsnew_doc1.xml')
     output1 = cStringIO.StringIO()        
     output2 = cStringIO.StringIO()        
     xml_print(doc, stream=output1)
     xml_print(doc2, stream=output2)
     self.assertEqual(output1.getvalue(), output2.getvalue())
     return
Ejemplo n.º 8
0
 def test_reading_building(self):
     doc = tree.entity()
     doc.xml_append(
         tree.processing_instruction(u'xml-stylesheet',
                                     u'href="classic.xsl" type="text/xml"'))
     A = tree.element(None, u'A')
     A.xml_attributes[u'a'] = u'b'
     A.xml_append(tree.text(u'One'))
     doc.xml_append(A)
     doc.xml_append(tree.comment(u"This is easy"))
     doc2 = amara.parse('docs/whatsnew_doc1.xml')
     output1 = cStringIO.StringIO()
     output2 = cStringIO.StringIO()
     xml_print(doc, stream=output1)
     xml_print(doc2, stream=output2)
     self.assertEqual(output1.getvalue(), output2.getvalue())
     return
Ejemplo n.º 9
0
 def _emitComment(self, text):
     text = text.replace(u"--",
                         u"- -")  # There cannot be "--" in XML comment
     self.cur.xml_append(tree.comment(text))
Ejemplo n.º 10
0
 def _emitComment(self, text):
     text = text.replace(u"--", u"- -")  # There cannot be "--" in XML comment
     self.cur.xml_append(tree.comment(text))