summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2020-09-20 10:14:54 -0400
committerCarlton Gibson <carlton@noumenal.es>2020-09-24 12:52:41 +0200
commite26a7a8ef41f0d69951affb21655cdc2cf94a209 (patch)
treedfaf58c61a3b23d25e61e21148bdb948663da25d /tests/test_utils
parent01974d7f7549b2dca2a729c3c1a1ea7d4585eb3a (diff)
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/>'.
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/tests.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 87e2f56979..51e3c0548a 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -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>', '')