#32547 closed Cleanup/optimization (fixed)
assertHTMLEqual()/assertHTMLNotEqual() allow invalid HTML.
Reported by: | François Poulain | Owned by: | Hasan Ramezani |
---|---|---|---|
Component: | Documentation | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Hi,
The docs for assertHTMLEqual says "html1 and html2 must be valid HTML.". The formulation suggest that html validation is enforced. But is is actually easy to get test succeeding with invalid html. Eg.
SimpleTestCase.assertHTMLEqual(None, '<div class="bling" class="blang">', '<div class="bling" class="blang">')
The code rely on Python's HTMLParser (https://docs.python.org/3/library/html.parser.html) for which the documentation states it produce parsers "able to parse invalid markup.".
I suggest to correct documentation and/or to enforce validation on the parser side.
How do you think about it?
Change History (7)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Component: | Testing framework → Documentation |
---|---|
Summary: | assertHTMLEqual allows invalid HTML → assertHTMLEqual()/assertHTMLNotEqual() allow invalid HTML. |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 4 years ago
Easy pickings: | set |
---|
comment:4 by , 4 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
I've created a PR and removed the must be valid HTML
and An AssertionError will be raised if one of them cannot be parsed.
from
assertHTMLEqual()
and assertHTMLNotEqual()
docs.
comment:5 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Agreed, we should clarify this in assertHTMLEqual(), assertHTMLNotEqual() docs and parse_html() docstring.