0

How can I compose an XML document, then test another data stream to compare the two for equivalent content?

For a test suite I want to call the function which generates an XML document, and assert that its structure and content are equal.

import the_real_system

test_input = make_test_data()

expected_xml_document = carefully_compose_the_expected_structure(
    test_input)

real_document = the_real_system.generate_output(test_input)

assert xml_documents_are_equivalent(real_document, expected_xml_document)

Is there an already implemented xml_documents_are_equivalent in a PyPI library?

bignose
  • 30,281
  • 14
  • 77
  • 110
  • 1
    Convert both to XML C14n form, and then you can just do a byte-for-byte comparison of the serializations. – Charles Duffy Oct 03 '17 at 23:28
  • Posible duplicate of [https://stackoverflow.com/questions/24492895/comparing-two-xml-files-in-python](https://stackoverflow.com/questions/24492895/comparing-two-xml-files-in-python). – eventHandler Oct 03 '17 at 23:32

0 Answers0