Skip to content
Browse files

[1.5.x] Fixed HTML comparisons of class="foo bar" and class="bar foo"…

… in tests

Refs #17758

Backport of 8bc410b from master
  • Loading branch information...
1 parent 00aea69 commit 2164cd00ecdb61774d05f5f278078a28c926779f @spookylukey spookylukey committed
Showing with 8 additions and 0 deletions.
  1. +8 −0 django/test/html.py
View
8 django/test/html.py
@@ -182,6 +182,14 @@ def handle_startendtag(self, tag, attrs):
self.handle_endtag(tag)
def handle_starttag(self, tag, attrs):
+ # Special case handling of 'class' attribute, so that comparisons of DOM
+ # instances are not sensitive to ordering of classes.
+ attrs = [
+ (name, " ".join(sorted(value.split(" "))))
+ if name == "class"
+ else (name, value)
+ for name, value in attrs
+ ]
element = Element(tag, attrs)
self.current.append(element)
if tag not in self.SELF_CLOSING_TAGS:

0 comments on commit 2164cd0

Please sign in to comment.
Something went wrong with that request. Please try again.