diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2012-12-24 02:11:32 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2012-12-24 02:21:36 +0000 |
| commit | 2164cd00ecdb61774d05f5f278078a28c926779f (patch) | |
| tree | c2e13712c10b610a675e65e5b4dc709a16a0bbf0 | |
| parent | 00aea69f06b5eb2f7f22e5422382cabe561c449f (diff) | |
[1.5.x] Fixed HTML comparisons of class="foo bar" and class="bar foo" in tests
Refs #17758
Backport of 8bc410b44536e03ee38a0087256faf367dd98dd9 from master
| -rw-r--r-- | django/test/html.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/test/html.py b/django/test/html.py index 274810cab4..2f6e4c9481 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -182,6 +182,14 @@ class Parser(HTMLParser): 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: |
