MCPcopy
hub / github.com/django/django / assertXMLEqual

Method assertXMLEqual

django/test/testcases.py:1063–1084  ·  view source on GitHub ↗

Assert that two XML snippets are semantically the same. Whitespace in most cases is ignored and attribute ordering is not significant. The arguments must be valid XML.

(self, xml1, xml2, msg=None)

Source from the content-addressed store, hash-verified

1061 self.assertNotEqual(data, expected_data, msg=msg)
1062
1063 def assertXMLEqual(self, xml1, xml2, msg=None):
1064 """
1065 Assert that two XML snippets are semantically the same.
1066 Whitespace in most cases is ignored and attribute ordering is not
1067 significant. The arguments must be valid XML.
1068 """
1069 try:
1070 result = compare_xml(xml1, xml2)
1071 except Exception as e:
1072 standardMsg = "First or second argument is not valid XML\n%s" % e
1073 self.fail(self._formatMessage(msg, standardMsg))
1074 else:
1075 if not result:
1076 standardMsg = "%s != %s" % (
1077 safe_repr(xml1, True),
1078 safe_repr(xml2, True),
1079 )
1080 diff = "\n" + "\n".join(
1081 difflib.ndiff(xml1.splitlines(), xml2.splitlines())
1082 )
1083 standardMsg = self._truncateMessage(standardMsg, diff)
1084 self.fail(self._formatMessage(msg, standardMsg))
1085
1086 def assertXMLNotEqual(self, xml1, xml2, msg=None):
1087 """

Calls 2

compare_xmlFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected