def test_writer(self): a = Element('a') b = SubElement(a, 'b') b.append(Comment('a comment')) c = SubElement(b, 'c', d = 'e') f = SubElement(c, 'f') f.text = 'g' h = SubElement(c, 'h') h.text = 'i << >> << &&' b.append(ProcessingInstruction('pdk', 'processing instruction')) tree = ElementTree(a) output = stringio() write_pretty_xml(tree, output) self.assert_equals_long(expected_xml_output, output.getvalue())
def test_xml_read_then_write(self): tree = parse_xml(stringio(expected_xml_output)) output = stringio() write_pretty_xml(tree, output) self.assert_equals_long(expected_xml_output, output.getvalue())