Loading diffoscope/comparators/xml.py +8 −5 Original line number Diff line number Diff line Loading @@ -131,11 +131,14 @@ class XMLFile(File): ) ] return [ Difference.from_text( difference = Difference.from_text( self.dumps(self), self.dumps(other), self.name, other.name ) ] if difference: difference.check_for_ordering_differences() return [difference] def dumps(self, file): """ Loading tests/comparators/test_xml.py +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ from ..utils.data import load_fixture, assert_diff xml_a = load_fixture("test1.xml") xml_b = load_fixture("test2.xml") xml_c = load_fixture("test3.xml") xml_d = load_fixture("test4.xml") invalid_xml = load_fixture("test_invalid.xml") Loading @@ -52,3 +54,12 @@ def differences(xml_a, xml_b): ) def test_diff(differences): assert_diff(differences[0], "test_xml_expected_diff") @pytest.mark.skipif( sys.version_info < (3, 8), reason="requires Python 3.8 or higher" ) def test_ordering_differences(xml_c, xml_d): diff = xml_c.compare(xml_d) assert diff.details[0].comments == ["Ordering differences only"] assert_diff(diff.details[0], "test_xml_ordering_differences_diff") tests/data/test3.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version='1.0' encoding='UTF-8' ?> <foo> <bar attr='foo'/> <bar attr='bar'/> </foo> tests/data/test4.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version='1.0' encoding='UTF-8' ?> <foo> <bar attr='bar'/> <bar attr='foo'/> </foo> tests/data/test_xml_ordering_differences_diff 0 → 100644 +7 −0 Original line number Diff line number Diff line @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <foo> - <bar attr="foo"/> <bar attr="bar"/> + <bar attr="foo"/> </foo> Loading
diffoscope/comparators/xml.py +8 −5 Original line number Diff line number Diff line Loading @@ -131,11 +131,14 @@ class XMLFile(File): ) ] return [ Difference.from_text( difference = Difference.from_text( self.dumps(self), self.dumps(other), self.name, other.name ) ] if difference: difference.check_for_ordering_differences() return [difference] def dumps(self, file): """ Loading
tests/comparators/test_xml.py +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ from ..utils.data import load_fixture, assert_diff xml_a = load_fixture("test1.xml") xml_b = load_fixture("test2.xml") xml_c = load_fixture("test3.xml") xml_d = load_fixture("test4.xml") invalid_xml = load_fixture("test_invalid.xml") Loading @@ -52,3 +54,12 @@ def differences(xml_a, xml_b): ) def test_diff(differences): assert_diff(differences[0], "test_xml_expected_diff") @pytest.mark.skipif( sys.version_info < (3, 8), reason="requires Python 3.8 or higher" ) def test_ordering_differences(xml_c, xml_d): diff = xml_c.compare(xml_d) assert diff.details[0].comments == ["Ordering differences only"] assert_diff(diff.details[0], "test_xml_ordering_differences_diff")
tests/data/test3.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version='1.0' encoding='UTF-8' ?> <foo> <bar attr='foo'/> <bar attr='bar'/> </foo>
tests/data/test4.xml 0 → 100644 +5 −0 Original line number Diff line number Diff line <?xml version='1.0' encoding='UTF-8' ?> <foo> <bar attr='bar'/> <bar attr='foo'/> </foo>
tests/data/test_xml_ordering_differences_diff 0 → 100644 +7 −0 Original line number Diff line number Diff line @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <foo> - <bar attr="foo"/> <bar attr="bar"/> + <bar attr="foo"/> </foo>