def test_simple_atom_entry(): '''Basic ns fixup upon mutation''' doc = bindery.parse(ATOMENTRY1) s = cStringIO.StringIO() xml_print(doc, stream=s) out = s.getvalue() #self.assertEqual(out, ATOMENTRY1) diff = treecompare.xml_diff(out, ATOMENTRY1) diff = '\n'.join(diff) assert not diff, "Expected=%r, returned=%r diff=%r" % (ATOMENTRY1, out, diff) #Make sure we can parse the result doc2 = bindery.parse(out)
def test_namespace_free_xhtml3(self): 'namespace-free XHTML' + '...as XML with pretty print' doc = self._build_namespace_free_xhtml() s = cStringIO.StringIO() xml_print(doc, stream=s, indent=True) out = s.getvalue() #self.assertEqual(out, ATOMENTRY1) diff = treecompare.xml_diff(out, XHTML_EXPECTED_3, whitespace=False) diff = '\n'.join(diff) self.assertFalse(diff, msg=(None, diff)) #Make sure we can parse the result doc2 = bindery.parse(out)
def test_minimal_document(self): 'minimal document with DOCTYPE' doc = amara.tree.entity() doc.xml_append(amara.tree.element(None, u'foo')) doc.xml_public_id = u'myPub' doc.xml_system_id = u'mySys' s = cStringIO.StringIO() xml_print(doc, stream=s) out = s.getvalue() #self.assertEqual(out, ATOMENTRY1) diff = treecompare.xml_diff(out, DOCTYPE_EXPECTED_1) diff = '\n'.join(diff) self.assertFalse(diff, msg=(None, diff))
def _assert_result(self, result): method = (None, self.force_method) if self.force_method else result.parameters.method omit_decl = result.parameters.omit_xml_declaration expected, compared = self.expected, result #print expected, compared if method == (None, 'xml') and not omit_decl: diff = treecompare.xml_diff(expected, compared) elif method == (None, 'html'): diff = treecompare.html_diff(expected, compared) else: expected = expected.splitlines() compared = compared.splitlines() diff = difflib.unified_diff(expected, compared, 'expected', 'compared', n=2, lineterm='') diff = '\n'.join(diff) self.assertFalse(diff, msg=(None, diff)) gc.collect()
def _assert_result(self, result): method = (None, self.force_method ) if self.force_method else result.parameters.method omit_decl = result.parameters.omit_xml_declaration expected, compared = self.expected, result #print expected, compared if method == (None, 'xml') and not omit_decl: diff = treecompare.xml_diff(expected, compared) elif method == (None, 'html'): diff = treecompare.html_diff(expected, compared) else: expected = expected.splitlines() compared = compared.splitlines() diff = difflib.unified_diff(expected, compared, 'expected', 'compared', n=2, lineterm='') diff = '\n'.join(diff) self.assertFalse(diff, msg=(None, diff)) gc.collect()