Fixed #25191 -- Added string diff to SimpleTestCase.assertXMLEqual() message.
This commit is contained in:
parent
c6c00fbfbb
commit
62d4074005
|
@ -784,6 +784,13 @@ class SimpleTestCase(unittest.TestCase):
|
|||
else:
|
||||
if not result:
|
||||
standardMsg = '%s != %s' % (safe_repr(xml1, True), safe_repr(xml2, True))
|
||||
diff = ('\n' + '\n'.join(
|
||||
difflib.ndiff(
|
||||
six.text_type(xml1).splitlines(),
|
||||
six.text_type(xml2).splitlines(),
|
||||
)
|
||||
))
|
||||
standardMsg = self._truncateMessage(standardMsg, diff)
|
||||
self.fail(self._formatMessage(msg, standardMsg))
|
||||
|
||||
def assertXMLNotEqual(self, xml1, xml2, msg=None):
|
||||
|
|
|
@ -710,6 +710,19 @@ class XMLEqualTests(SimpleTestCase):
|
|||
with self.assertRaises(AssertionError):
|
||||
self.assertXMLEqual(xml1, xml2)
|
||||
|
||||
def test_simple_equal_raises_message(self):
|
||||
xml1 = "<elem attr1='a' />"
|
||||
xml2 = "<elem attr2='b' attr1='a' />"
|
||||
|
||||
msg = '''{xml1} != {xml2}
|
||||
- <elem attr1='a' />
|
||||
+ <elem attr2='b' attr1='a' />
|
||||
? ++++++++++
|
||||
'''.format(xml1=repr(xml1), xml2=repr(xml2))
|
||||
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
self.assertXMLEqual(xml1, xml2)
|
||||
|
||||
def test_simple_not_equal(self):
|
||||
xml1 = "<elem attr1='a' attr2='c' />"
|
||||
xml2 = "<elem attr1='a' attr2='b' />"
|
||||
|
|
Loading…
Reference in New Issue