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

Comment (by Baptiste Mispelon):

 Digging into this, the issue appears to be that `django.test.html.Element`
 has a different logic in its `__eq__` vs `__str__`.

 In particular, `__eq__` [1] has this comment:
 {{{
 # attributes without a value is same as attribute with value that
 # equals the attributes name:
 # <input checked> == <input checked="checked">
 }}}

 Whereas `__str__` will simply drop the value if it's false-ish.

 But I'm not sure that's a correct interpretation of the HTML spec on
 boolean attributes [2].
 From what I understand not all HTML attributes can be used without a
 value, but I can't seem to find an exhaustive list. A random comment on
 the internet suggests going through the complete HTML5 spec [3] and
 looking for the phrase "is a boolean".

 With Django's current approach, the two elements `<input value>` and
 `<input value="value">` would be considered equivalent but I'm not sure
 that's correct.


 [1]
 
https://github.com/django/django/blob/54d91795408c878ad335226a87a44961d7f646a9/django/test/html.py#L61
 [2] https://www.w3.org/TR/html52/infrastructure.html#sec-boolean-
 attributes
 [3] https://html.spec.whatwg.org/

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32556#comment:2>
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.69d869f3e535bfb845be498d50aa9c93%40djangoproject.com.

Reply via email to