summaryrefslogtreecommitdiff
path: root/django/test/html.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 12:32:08 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-12 14:44:40 +0200
commitd4a0b27838c815af87698920cc4db7d2afd6f05b (patch)
tree6fedc7203389ab1f80f8cc7e913230c51e9b8776 /django/test/html.py
parent79d62a71751140315227891bbe175630f9d3edc3 (diff)
[py3] Refactored __unicode__ to __str__.
* Renamed the __unicode__ methods * Applied the python_2_unicode_compatible decorator * Removed the StrAndUnicode mix-in that is superseded by python_2_unicode_compatible * Kept the __unicode__ methods in classes that specifically test it under Python 2
Diffstat (limited to 'django/test/html.py')
-rw-r--r--django/test/html.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/test/html.py b/django/test/html.py
index acdb4ffd14..274810cab4 100644
--- a/django/test/html.py
+++ b/django/test/html.py
@@ -8,6 +8,7 @@ import re
from django.utils.encoding import force_text
from django.utils.html_parser import HTMLParser, HTMLParseError
from django.utils import six
+from django.utils.encoding import python_2_unicode_compatible
WHITESPACE = re.compile('\s+')
@@ -17,6 +18,7 @@ def normalize_whitespace(string):
return WHITESPACE.sub(' ', string)
+@python_2_unicode_compatible
class Element(object):
def __init__(self, name, attributes):
self.name = name
@@ -117,7 +119,7 @@ class Element(object):
def __getitem__(self, key):
return self.children[key]
- def __unicode__(self):
+ def __str__(self):
output = '<%s' % self.name
for key, value in self.attributes:
if value:
@@ -136,11 +138,12 @@ class Element(object):
return six.text_type(self)
+@python_2_unicode_compatible
class RootElement(Element):
def __init__(self):
super(RootElement, self).__init__(None, ())
- def __unicode__(self):
+ def __str__(self):
return ''.join(six.text_type(c) for c in self.children)