summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/utils/text.py4
-rw-r--r--tests/utils_tests/test_text.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index eeff5c5a2e..93c33b3351 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -365,12 +365,12 @@ def _replace_entity(match):
c = int(text[1:], 16)
else:
c = int(text)
- return unichr(c)
+ return six.unichr(c)
except ValueError:
return match.group(0)
else:
try:
- return unichr(html_entities.name2codepoint[text])
+ return six.unichr(html_entities.name2codepoint[text])
except (ValueError, KeyError):
return match.group(0)
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index c9dde6b1b3..dd72d26e06 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -106,3 +106,16 @@ class TestUtilsText(SimpleTestCase):
)
for value, output in items:
self.assertEqual(text.slugify(value), output)
+
+ def test_unescape_entities(self):
+ items = [
+ ('', ''),
+ ('foo', 'foo'),
+ ('&', '&'),
+ ('&', '&'),
+ ('&', '&'),
+ ('foo & bar', 'foo & bar'),
+ ('foo & bar', 'foo & bar'),
+ ]
+ for value, output in items:
+ self.assertEqual(text.unescape_entities(value), output)