summaryrefslogtreecommitdiff
path: root/docs
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 /docs
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 'docs')
-rw-r--r--docs/releases/1.5.txt5
-rw-r--r--docs/topics/testing.txt19
2 files changed, 24 insertions, 0 deletions
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
index d87ec36204..e99b2fd578 100644
--- a/docs/releases/1.5.txt
+++ b/docs/releases/1.5.txt
@@ -198,6 +198,11 @@ Django 1.5 also includes several smaller improvements worth noting:
* The loaddata management command now supports an `ignorenonexistent` option to
ignore data for fields that no longer exist.
+* :meth:`~django.test.SimpleTestCase.assertXMLEqual` and
+ :meth:`~django.test.SimpleTestCase.assertXMLNotEqual` new assertions allow
+ you to test equality for XML content at a semantic level, without caring for
+ syntax differences (spaces, attribute order, etc.).
+
Backwards incompatible changes in 1.5
=====================================
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index 3950e1c917..895e721ef5 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -1783,6 +1783,25 @@ your test suite.
``html1`` and ``html2`` must be valid HTML. An ``AssertionError`` will be
raised if one of them cannot be parsed.
+.. method:: SimpleTestCase.assertXMLEqual(xml1, xml2, msg=None)
+
+ .. versionadded:: 1.5
+
+ Asserts that the strings ``xml1`` and ``xml2`` are equal. The
+ comparison is based on XML semantics. Similarily to
+ :meth:`~SimpleTestCase.assertHTMLEqual`, the comparison is
+ made on parsed content, hence only semantic differences are considered, not
+ syntax differences. When unvalid XML is passed in any parameter, an
+ ``AssertionError`` is always raised, even if both string are identical.
+
+.. method:: SimpleTestCase.assertXMLNotEqual(xml1, xml2, msg=None)
+
+ .. versionadded:: 1.5
+
+ Asserts that the strings ``xml1`` and ``xml2`` are *not* equal. The
+ comparison is based on XML semantics. See
+ :meth:`~SimpleTestCase.assertXMLEqual` for details.
+
.. _topics-testing-email:
Email services