#32556: assertHTMLEqual gives a confusing error message with empty attributes
-----------------------------------+------------------------------------
     Reporter:  Baptiste Mispelon  |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  dev
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for this report.

 > ''A boolean attribute without a value assigned to it (e.g. checked) is
 implicitly equivalent to one that has the empty string assigned to it
 (i.e. checked="")''

 I think we should stick to this, without checking if an attribute is
 really a boolean attribute or not according to spec. `assertHTMLEqual()`
 already allows invalid HTML (see #32547). I suggest checking if the values
 are truthy:

 {{{
 diff --git a/django/test/html.py b/django/test/html.py
 index 486a0d358d..d443c118e2 100644
 --- a/django/test/html.py
 +++ b/django/test/html.py
 @@ -64,9 +64,9 @@ class Element:
              for i in range(len(self.attributes)):
                  attr, value = self.attributes[i]
                  other_attr, other_value = element.attributes[i]
 -                if value is None:
 +                if not value:
                      value = attr
 -                if other_value is None:
 +                if not other_value:
                      other_value = other_attr
                  if attr != other_attr or value != other_value:
                      return False
 }}}

 Would you like to provide a patch?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32556#comment:3>
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/067.2801131874cc65d1c33e84c5da860af8%40djangoproject.com.

Reply via email to