chipx86 got a fish trophy!
Change some HTML-related assertions to use assertHTMLEqual().
Review Request #9669 — Created Feb. 18, 2018 and submitted — Latest diff uploaded
We had some unit tests that were checking the HTML output of functions,
expecting certain attribute orders and whitespace. These were fine with
Django 1.6, but were changed in both newer versions of Django and could
be impacted by dictionary-related ordering in Python 3. The way to
safely check for HTML string equality is through Django's
assertHTMLEqual()
(orassertInHTML()
), which this change is making
more use of.The assertions for
ConditionsWidget
required a bit more work than
simply switching the equality check. We were checking an entire
resulting dictionary at once, which performed strict string equality
checks. To address this, the tests had to be changed to check for each
of the fields in the dictionary (dealing with nested values in the
process) independently, so that we couldassertHTMLEqual()
the HTML
parts. This has the added benefit of helping trace specific regressions
in the output without having to manually compare large dictionaries in
test failure results.
Unit tests pass on Django 1.6 and 1.11 (when used with other in-progress
compatibility changes).