Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed HTML comparisons of class="foo bar" and class="bar foo" in tests

Refs #17758
  • Loading branch information...
commit 8bc410b44536e03ee38a0087256faf367dd98dd9 1 parent 1ae64e9
Luke Plant spookylukey authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 django/test/html.py
8 django/test/html.py
View
@@ -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.