Opened 4 years ago
Last modified 4 years ago
#32547 closed Cleanup/optimization
assertHTMLEqual allows invalid HTML — at Initial Version
Reported by: | François Poulain | Owned by: | nobody |
---|---|---|---|
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
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?