mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #27753 -- Deprecated django.utils.text.unescape_entities().
The function was undocumented and only required for compatibility with Python 2. Code should use Python's html.unescape() that was added in Python 3.4.
This commit is contained in:
committed by
Mariusz Felisiak
parent
6b736dd074
commit
b915b9f10f
@@ -1,8 +1,9 @@
|
||||
import json
|
||||
import sys
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.utils import text
|
||||
from django.utils.deprecation import RemovedInDjango40Warning
|
||||
from django.utils.functional import lazystr
|
||||
from django.utils.text import format_lazy
|
||||
from django.utils.translation import gettext_lazy, override
|
||||
@@ -184,6 +185,7 @@ class TestUtilsText(SimpleTestCase):
|
||||
# interning the result may be useful, e.g. when fed to Path.
|
||||
self.assertEqual(sys.intern(text.slugify('a')), 'a')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango40Warning)
|
||||
def test_unescape_entities(self):
|
||||
items = [
|
||||
('', ''),
|
||||
@@ -200,6 +202,14 @@ class TestUtilsText(SimpleTestCase):
|
||||
self.assertEqual(text.unescape_entities(value), output)
|
||||
self.assertEqual(text.unescape_entities(lazystr(value)), output)
|
||||
|
||||
def test_unescape_entities_deprecated(self):
|
||||
msg = (
|
||||
'django.utils.text.unescape_entities() is deprecated in favor of '
|
||||
'html.unescape().'
|
||||
)
|
||||
with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
|
||||
text.unescape_entities('foo')
|
||||
|
||||
def test_unescape_string_literal(self):
|
||||
items = [
|
||||
('"abc"', 'abc'),
|
||||
|
||||
Reference in New Issue
Block a user