Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fix #21185: Added tests for unescape_entities.

Also fixed a py3 incompatibility.
Thanks to brutasse for the report.

Backport of 3754f4a from master.
  • Loading branch information...
commit 73ffe26816738c15515e5764e96c056f0d98559a 1 parent cb95516
Baptiste Mispelon authored
4  django/utils/text.py
@@ -381,12 +381,12 @@ def _replace_entity(match):
381 381
                 c = int(text[1:], 16)
382 382
             else:
383 383
                 c = int(text)
384  
-            return unichr(c)
  384
+            return six.unichr(c)
385 385
         except ValueError:
386 386
             return match.group(0)
387 387
     else:
388 388
         try:
389  
-            return unichr(html_entities.name2codepoint[text])
  389
+            return six.unichr(html_entities.name2codepoint[text])
390 390
         except (ValueError, KeyError):
391 391
             return match.group(0)
392 392
 
13  tests/regressiontests/utils/text.py
@@ -121,3 +121,16 @@ def test_slugify(self):
121 121
         )
122 122
         for value, output in items:
123 123
             self.assertEqual(text.slugify(value), output)
  124
+
  125
+    def test_unescape_entities(self):
  126
+        items = [
  127
+            ('', ''),
  128
+            ('foo', 'foo'),
  129
+            ('&', '&'),
  130
+            ('&', '&'),
  131
+            ('&', '&'),
  132
+            ('foo & bar', 'foo & bar'),
  133
+            ('foo & bar', 'foo & bar'),
  134
+        ]
  135
+        for value, output in items:
  136
+            self.assertEqual(text.unescape_entities(value), output)

0 notes on commit 73ffe26

Please sign in to comment.
Something went wrong with that request. Please try again.