Open
Description
Describe the bug
When trying to get Python tests pass in Travis Windows environment, test_xml_insert()
was failing with:
def test_xml_insert():
with open(os.path.join(DIR_PATH, "web.xml")) as base_xml:
out = insert_file(base_xml.read(),
os.path.join(DIR_PATH, "insert.xml"))
with open(os.path.join(DIR_PATH, "new.xml")) as expected_xml:
> assert out == expected_xml.read()
E assert '<?xml versio...n\n</web-app>' == '<?xml versio...n\n</web-app>'
E <?xml version='1.0' encoding='utf8'?>
E - <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
E ? --------------
E + <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
E ? ++++++++++++++
E
Clearly, the failure happens because some of the attributes (version
) were reordered in the output.
To Reproduce
run the test in Travis Windows environment.
Expected behavior
the test should be robust
Additional context
The test should compare XML trees, ala https://stackoverflow.com/questions/24492895/comparing-two-xml-files-in-python