mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #27906 -- Fixed test tools counting of HTML matches for subsets of elements.
Previously examples such as '<a/><b/>' would not match in '<a/><b/><c/>'.
This commit is contained in:
parent
01974d7f75
commit
e26a7a8ef4
2 changed files with 38 additions and 1 deletions
|
@ -768,11 +768,30 @@ class HTMLEqualTests(SimpleTestCase):
|
|||
dom2 = parse_html('<p>foo<p>bar</p></p>')
|
||||
self.assertEqual(dom2.count(dom1), 0)
|
||||
|
||||
# html with a root element contains the same html with no root element
|
||||
# HTML with a root element contains the same HTML with no root element.
|
||||
dom1 = parse_html('<p>foo</p><p>bar</p>')
|
||||
dom2 = parse_html('<div><p>foo</p><p>bar</p></div>')
|
||||
self.assertEqual(dom2.count(dom1), 1)
|
||||
|
||||
# Target of search is a sequence of child elements and appears more
|
||||
# than once.
|
||||
dom2 = parse_html('<div><p>foo</p><p>bar</p><p>foo</p><p>bar</p></div>')
|
||||
self.assertEqual(dom2.count(dom1), 2)
|
||||
|
||||
# Searched HTML has additional children.
|
||||
dom1 = parse_html('<a/><b/>')
|
||||
dom2 = parse_html('<a/><b/><c/>')
|
||||
self.assertEqual(dom2.count(dom1), 1)
|
||||
|
||||
# No match found in children.
|
||||
dom1 = parse_html('<b/><a/>')
|
||||
self.assertEqual(dom2.count(dom1), 0)
|
||||
|
||||
# Target of search found among children and grandchildren.
|
||||
dom1 = parse_html('<b/><b/>')
|
||||
dom2 = parse_html('<a><b/><b/></a><b/><b/>')
|
||||
self.assertEqual(dom2.count(dom1), 2)
|
||||
|
||||
def test_parsing_errors(self):
|
||||
with self.assertRaises(AssertionError):
|
||||
self.assertHTMLEqual('<p>', '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue