Refs #30399 -- Made assertHTMLEqual normalize character and entity references.

This commit is contained in:
Jon Dufresne 2019-05-09 06:55:32 -07:00 committed by Carlton Gibson
parent af5ec222cc
commit 48235ba807
4 changed files with 40 additions and 11 deletions

View file

@ -612,6 +612,31 @@ class HTMLEqualTests(SimpleTestCase):
'<input type="text" id="id_name" />',
'<input type="password" id="id_name" />')
def test_normalize_refs(self):
pairs = [
('&#39;', '&#x27;'),
('&#39;', "'"),
('&#x27;', '&#39;'),
('&#x27;', "'"),
("'", '&#39;'),
("'", '&#x27;'),
('&amp;', '&#38;'),
('&amp;', '&#x26;'),
('&amp;', '&'),
('&#38;', '&amp;'),
('&#38;', '&#x26;'),
('&#38;', '&'),
('&#x26;', '&amp;'),
('&#x26;', '&#38;'),
('&#x26;', '&'),
('&', '&amp;'),
('&', '&#38;'),
('&', '&#x26;'),
]
for pair in pairs:
with self.subTest(repr(pair)):
self.assertHTMLEqual(*pair)
def test_complex_examples(self):
self.assertHTMLEqual(
"""<tr><th><label for="id_first_name">First name:</label></th>