summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-10-06 13:14:11 +0200
committerClaude Paroz <claude@2xlibre.net>2012-10-06 13:14:50 +0200
commit117e99511e0985701780ed1bcd3afd456e244ae3 (patch)
tree796c63acf8b32f7f1ba4563abc8e006c9dcd98f0 /tests
parent6d46c740d80b0c7f75064bc6bb4d99b15b106ba4 (diff)
Added assertXML[Not]Equal assertions
This is especially needed to compare XML when hash randomization is on, as attribute order may vary. Refs #17758, #19038. Thanks Taylor Mitchell for the initial patch, and Ian Clelland for review and cleanup.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/test_utils/tests.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index 12c639cee1..dec157eacb 100644
--- a/tests/regressiontests/test_utils/tests.py
+++ b/tests/regressiontests/test_utils/tests.py
@@ -450,6 +450,41 @@ class HTMLEqualTests(TestCase):
self.assertContains(response, '<p class="help">Some help text for the title (with unicode ŠĐĆŽćžšđ)</p>', html=True)
+class XMLEqualTests(TestCase):
+ def test_simple_equal(self):
+ xml1 = "<elem attr1='a' attr2='b' />"
+ xml2 = "<elem attr1='a' attr2='b' />"
+ self.assertXMLEqual(xml1, xml2)
+
+ def test_simple_equal_unordered(self):
+ xml1 = "<elem attr1='a' attr2='b' />"
+ xml2 = "<elem attr2='b' attr1='a' />"
+ self.assertXMLEqual(xml1, xml2)
+
+ def test_simple_equal_raise(self):
+ xml1 = "<elem attr1='a' />"
+ xml2 = "<elem attr2='b' attr1='a' />"
+ with self.assertRaises(AssertionError):
+ self.assertXMLEqual(xml1, xml2)
+
+ def test_simple_not_equal(self):
+ xml1 = "<elem attr1='a' attr2='c' />"
+ xml2 = "<elem attr1='a' attr2='b' />"
+ self.assertXMLNotEqual(xml1, xml2)
+
+ def test_simple_not_equal_raise(self):
+ xml1 = "<elem attr1='a' attr2='b' />"
+ xml2 = "<elem attr2='b' attr1='a' />"
+ with self.assertRaises(AssertionError):
+ self.assertXMLNotEqual(xml1, xml2)
+
+ def test_parsing_errors(self):
+ xml_unvalid = "<elem attr1='a attr2='b' />"
+ xml2 = "<elem attr2='b' attr1='a' />"
+ with self.assertRaises(AssertionError):
+ self.assertXMLNotEqual(xml_unvalid, xml2)
+
+
class SkippingExtraTests(TestCase):
fixtures = ['should_not_be_loaded.json']