def testUnicode(self): x = Element("x") x.comment(u"\u03a3") x.flatten() self.assertEquals(unicode(x), u"<x><!-- \u03a3 --></x>") x = Element(u"\u03a3") self.assertEquals(unicode(x), u"<\u03a3/>") x = Element("x", [(u"\u03a3", "foo")]) self.assertEquals(unicode(x), u'<x \u03a3="foo"/>') x = Element("x", [("foo", u"\u03a3")]) self.assertEquals(unicode(x), u'<x foo="\u03a3"/>') x = Element("x") x.text(u"\u03a3") x.flatten() self.assertEquals(unicode(x), u"<x>\u03a3</x>")
def testUnicode(self): x = Element("x") x.comment(u'\u03a3') x.flatten() self.assertEquals(unicode(x), u'<x><!-- \u03a3 --></x>') x = Element(u'\u03a3') self.assertEquals(unicode(x), u'<\u03a3/>') x = Element('x', [(u'\u03a3', 'foo')]) self.assertEquals(unicode(x), u'<x \u03a3="foo"/>') x = Element('x', [('foo', u'\u03a3')]) self.assertEquals(unicode(x), u'<x foo="\u03a3"/>') x = Element('x') x.text(u'\u03a3') x.flatten() self.assertEquals(unicode(x), u'<x>\u03a3</x>')
def testFlatten(self): x = Element("x") x.text("y") x.flatten() self.assertEquals(str(x), "<x>y</x>")
def testText(self): x = Element("x") x.text("y") self.assertEquals(str(x), "<x>\n\ty\n</x>")