assertInHTML('<a/><b/>', '<a/><b/><c/>') fails
As the title indicates, HTML substring search fails to find matches in the haystack if the needle consists of multiple sibling elements that do appear in the haystack with more siblings on the same level.
This is a follow-up to #24112, which fixed the simple case when the list of children of an element matches exactly the list of children of the needle.
A simple, but somewhat sub-optimal solution could be to use two nested loops to compare the children of self
with the children of the root element; an optimal, but much more complex solution would be to implement a variant of KMP on the children of self
.
Change History
(9)
Description: |
modified (diff)
|
Summary: |
assertContains('<a/><b/><c/>', '<a/><b/>', html=True) fails → assertInHTML('<a/><b/>', '<a/><b/><c/>') fails
|
Triage Stage: |
Unreviewed → Accepted
|
Owner: |
changed from Michal Petrucha to Jacob Walls
|
Triage Stage: |
Accepted → Ready for checkin
|
Needs tests: |
set
|
Patch needs improvement: |
set
|
Triage Stage: |
Ready for checkin → Accepted
|
Needs tests: |
unset
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
We already have one loop so, yes, the simpler approach is to simply introduce an inner loop to handle this case. I have something working that I will proofread and submit sometime this week.