def assert_xml_equal(a, b): """ Compare two XML artifacts for equality. :param a, b: Paths to XML files, or a file-like object containing the XML contents. """ tools.assert_equal(tostring(parse(a).getroot()), tostring(parse(b).getroot()))
def test_tostring(self): nrml = etree.Element( 'nrml', {'xmlns': 'http://openquake.org/xmlns/nrml/0.4'}) em = etree.SubElement( nrml, 'exposureModel', {'id': "my_exposure_model_for_population", 'category': "population", 'taxonomySource': "fake population datasource"}) descr = etree.SubElement(em, 'description') descr.text = 'Sample population' etree.SubElement(em, 'assets') self.assertEqual(tostring(nrml), '''\ <nrml xmlns="http://openquake.org/xmlns/nrml/0.4" > <exposureModel category="population" taxonomySource="fake population datasource" id="my_exposure_model_for_population" > <description> Sample population </description> <assets> </assets> </exposureModel> </nrml> ''')
def test_tostring(self): nrml = etree.Element('nrml', {'xmlns': 'http://openquake.org/xmlns/nrml/0.4'}) em = etree.SubElement( nrml, 'exposureModel', { 'id': "my_exposure_model_for_population", 'category': "population", 'taxonomySource': "fake population datasource" }) descr = etree.SubElement(em, 'description') descr.text = 'Sample population' etree.SubElement(em, 'assets') self.assertEqual( tostring(nrml), '''\ <nrml xmlns="http://openquake.org/xmlns/nrml/0.4" > <exposureModel category="population" taxonomySource="fake population datasource" id="my_exposure_model_for_population" > <description> Sample population </description> <assets> </assets> </exposureModel> </nrml> ''')