#33236: assertHTMLEqual shows incorrect diff
---------------------------------------------+------------------------
               Reporter:  Pratyush Mittal    |          Owner:  nobody
                   Type:  Bug                |         Status:  new
              Component:  Testing framework  |        Version:  3.2
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  1
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  1
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 The diff shown in the error message of assertHTMLEqual seems to be
 converting escaped HTML text to unescaped text.

 This makes it hard to write tests when testing XSS vulnerabilities in our
 tags and filters. Though the assertions work correct, the error messages
 don't show the correct differences.

 **Steps to reproduce**

 {{{
 from django.test import TestCase

 class UtilsTestCase(TestCase):
 def test_assersion(self):
         escaped = "<p>&lt;foo&gt;</p>"
         raw = "<p><foo></p>"
         self.assertHTMLEqual(escaped, raw)
 }}}

 **Expected Output**

 {{{
 AssertionError: <p>
 &lt;foo&gt;
 </p> != <p>
 <foo>
 </p>
   <p>
 - &lt;foo&gt;
 + <foo>
   </p>
 }}}

 **Actual Output**

 {{{
 AssertionError: <p>
 <foo>
 </p> != <p>
 <foo>
 </p>
   <p>
   <foo>
   </p>
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33236>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/057.745e56a3f694aab4ad071c2223b9c960%40djangoproject.com.

Reply via email to