Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 2164cd00ecdb61774d05f5f278078a28c926779f 1 parent 00aea69
@spookylukey spookylukey authored
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:
Please sign in to comment.
Something went wrong with that request. Please try again.