mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
Fixed #33236 -- Fixed assertHTMLEqual() error messages for escaped HTML.
This commit is contained in:
parent
073b7b5915
commit
f38458fe56
2 changed files with 25 additions and 3 deletions
|
|
@ -868,6 +868,11 @@ class HTMLEqualTests(SimpleTestCase):
|
|||
dom2 = parse_html('<a><b/><b/></a><b/><b/>')
|
||||
self.assertEqual(dom2.count(dom1), 2)
|
||||
|
||||
def test_root_element_escaped_html(self):
|
||||
html = '<br>'
|
||||
parsed = parse_html(html)
|
||||
self.assertEqual(str(parsed), html)
|
||||
|
||||
def test_parsing_errors(self):
|
||||
with self.assertRaises(AssertionError):
|
||||
self.assertHTMLEqual('<p>', '')
|
||||
|
|
@ -882,6 +887,17 @@ class HTMLEqualTests(SimpleTestCase):
|
|||
with self.assertRaises(HTMLParseError):
|
||||
parse_html('</p>')
|
||||
|
||||
def test_escaped_html_errors(self):
|
||||
msg = (
|
||||
'<p>\n<foo>\n</p>'
|
||||
' != '
|
||||
'<p>\n<foo>\n</p>\n'
|
||||
)
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
self.assertHTMLEqual('<p><foo></p>', '<p><foo></p>')
|
||||
with self.assertRaisesMessage(AssertionError, msg):
|
||||
self.assertHTMLEqual('<p><foo></p>', '<p><foo></p>')
|
||||
|
||||
def test_contains_html(self):
|
||||
response = HttpResponse('''<body>
|
||||
This is a form: <form method="get">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue