mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #24046 -- Deprecated the "escape" half of utils.safestring.
This commit is contained in:
parent
c3e1086949
commit
2f0e0eee45
13 changed files with 87 additions and 20 deletions
|
@ -1,8 +1,9 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.template import Context, Template
|
||||
from django.test import SimpleTestCase
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.utils import html, six, text
|
||||
from django.utils.deprecation import RemovedInDjango20Warning
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.functional import lazy, lazystr
|
||||
from django.utils.safestring import (
|
||||
|
@ -62,11 +63,13 @@ class SafeStringTest(SimpleTestCase):
|
|||
def test_mark_safe_lazy_result_implements_dunder_html(self):
|
||||
self.assertEqual(mark_safe(lazystr('a&b')).__html__(), 'a&b')
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
def test_mark_for_escaping(self):
|
||||
s = mark_for_escaping('a&b')
|
||||
self.assertRenderEqual('{{ s }}', 'a&b', s=s)
|
||||
self.assertRenderEqual('{{ s }}', 'a&b', s=mark_for_escaping(s))
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
def test_mark_for_escaping_object_implementing_dunder_html(self):
|
||||
e = customescape('<a&b>')
|
||||
s = mark_for_escaping(e)
|
||||
|
@ -75,6 +78,7 @@ class SafeStringTest(SimpleTestCase):
|
|||
self.assertRenderEqual('{{ s }}', '<<a&b>>', s=s)
|
||||
self.assertRenderEqual('{{ s|force_escape }}', '<a&b>', s=s)
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
def test_mark_for_escaping_lazy(self):
|
||||
s = lazystr('a&b')
|
||||
b = lazybytes(b'a&b')
|
||||
|
@ -83,6 +87,7 @@ class SafeStringTest(SimpleTestCase):
|
|||
self.assertIsInstance(mark_for_escaping(b), EscapeData)
|
||||
self.assertRenderEqual('{% autoescape off %}{{ s }}{% endautoescape %}', 'a&b', s=mark_for_escaping(s))
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango20Warning)
|
||||
def test_mark_for_escaping_object_implementing_dunder_str(self):
|
||||
class Obj(object):
|
||||
def __str__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue