def testWriteTagData(self):
     xw = XMLWriter()
     xw.pushTag('tag')
     xw.writeTag('tag2', data='data')
     self.assertEquals(xw.getXML(),
                       self._addXMLHeader(xw,
                         '<tag>\n  <tag2>data</tag2>\n'))
 def testWriteTagAttrData(self):
     xw = XMLWriter()
     xw.pushTag('tag')
     xw.writeTag('tag2', [('attr', 'value')], data='data')
     self.assertEquals(xw.getXML(),
                       self._addXMLHeader(xw,
                         '<tag>\n  <tag2 attr="value">data</tag2>\n'))
示例#3
0
 def testWriteLine(self):
     xw = XMLWriter()
     xw.writeLine('foo')
     self.assertEquals(xw.getXML(), 'foo\n')
     xw.pushTag('tag')
     self.assertEquals(xw.getXML(), 'foo\n<tag>\n')
     xw.writeLine('bar')
     self.assertEquals(xw.getXML(), 'foo\n<tag>\n  bar\n')
 def testWriteLine(self):
     xw = XMLWriter()
     xw.writeLine('foo')
     self.assertEquals(xw.getXML(), self._addXMLHeader(xw, 'foo\n'))
     xw.pushTag('tag')
     self.assertEquals(xw.getXML(), self._addXMLHeader(xw, 'foo\n<tag>\n'))
     xw.writeLine('bar')
     self.assertEquals(xw.getXML(),
                       self._addXMLHeader(xw, 'foo\n<tag>\n  bar\n'))
示例#5
0
    def testPush(self):
        xw = XMLWriter()
        xw.pushTag('first')
        self.assertEquals(xw.getXML(), "<first>\n")
        xw.popTag()
        self.assertEquals(xw.getXML(), "<first>\n</first>\n")

        xw = XMLWriter()
        xw.pushTag('first', [('attr1', 'a'),
                             ('attr2', 'b')])
        self.assertEquals(xw.getXML(), '<first attr1="a" attr2="b">\n')
        xw.popTag()
示例#6
0
 def testIndent(self):
     xw = XMLWriter()
     xw.pushTag('tag',
               [('long-attribute-name-number-one', 'value'),
                ('long-attribute-name-number-two', 'value'),
                ('long-attribute-name-number-three', 'value')])
     xw.popTag()
     self.assertEquals(
         xw.getXML(),
         ('<tag long-attribute-name-number-one="value"\n'
          '     long-attribute-name-number-two="value"\n'
          '     long-attribute-name-number-three="value">\n'
          '</tag>\n'))
 def testIndent(self):
     xw = XMLWriter()
     xw.pushTag('tag',
               [('long-attribute-name-number-one', 'value'),
                ('long-attribute-name-number-two', 'value'),
                ('long-attribute-name-number-three', 'value')])
     xw.popTag()
     self.assertEquals(
         xw.getXML(),
         self._addXMLHeader(xw,
             ('<tag long-attribute-name-number-one="value"\n'
             '     long-attribute-name-number-two="value"\n'
             '     long-attribute-name-number-three="value">\n'
             '</tag>\n')))
    def testPush(self):
        xw = XMLWriter()
        xw.pushTag('first')
        self.assertEquals(xw.getXML(), self._addXMLHeader(xw, "<first>\n"))
        xw.popTag()
        self.assertEquals(xw.getXML(),
                          self._addXMLHeader(xw, "<first>\n</first>\n"))

        xw = XMLWriter()
        xw.pushTag('first', [('attr1', 'a'),
                             ('attr2', 'b')])
        self.assertEquals(xw.getXML(),
                          self._addXMLHeader(xw,
                            '<first attr1="a" attr2="b">\n'))
        xw.popTag()
 def testWriteTag(self):
     xw = XMLWriter()
     xw.pushTag('tag')
     xw.writeTag('tag2')
     self.assertEquals(xw.getXML(),
                       self._addXMLHeader(xw, '<tag>\n  <tag2/>\n'))
示例#10
0
 def testWriteTagAttr(self):
     xw = XMLWriter()
     xw.pushTag('tag')
     xw.writeTag('tag2', [('attr', 'value')])
     self.assertEquals(xw.getXML(),
                       '<tag>\n  <tag2 attr="value"/>\n')