summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2014-02-05 05:16:39 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2014-02-05 21:32:17 +0100
commit8864d2478946506db22d2d2d37585f55536fb358 (patch)
tree1d7378103606456fe06e0a42d3d7f98cf97d052d /tests
parentfd3fa851b592700a8b04af46f626454db0db02e4 (diff)
[1.6.x] Revert "Fixed #20296 -- Allowed SafeData and EscapeData to be lazy"
This reverts commit 2ee447fb5f8974b432d3dd421af9a242215aea44. That commit introduced a regression (#21882) and didn't really do what it was supposed to: while it did delay the evaluation of lazy objects passed to mark_safe(), they weren't actually marked as such so they could end up being escaped twice. Refs #21882. Backport of a878bf9b093bf15d751b070d132fec52a7523a47 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/utils_tests/test_safestring.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py
index a6f0c0a01c..3953f82362 100644
--- a/tests/utils_tests/test_safestring.py
+++ b/tests/utils_tests/test_safestring.py
@@ -4,9 +4,8 @@ from __future__ import absolute_import, unicode_literals
from django.template import Template, Context
from django.test import TestCase
from django.utils.encoding import force_text, force_bytes
-from django.utils.functional import lazy, Promise
-from django.utils.html import escape, conditional_escape
-from django.utils.safestring import mark_safe, mark_for_escaping
+from django.utils.functional import lazy
+from django.utils.safestring import mark_safe, mark_for_escaping, SafeData, EscapeData
from django.utils import six
from django.utils import translation
@@ -30,8 +29,8 @@ class SafeStringTest(TestCase):
s = lazystr('a&b')
b = lazybytes(b'a&b')
- self.assertIsInstance(mark_safe(s), Promise)
- self.assertIsInstance(mark_safe(b), Promise)
+ self.assertIsInstance(mark_safe(s), SafeData)
+ self.assertIsInstance(mark_safe(b), SafeData)
self.assertRenderEqual('{{ s }}', 'a&b', s=mark_safe(s))
def test_mark_for_escaping(self):
@@ -43,11 +42,6 @@ class SafeStringTest(TestCase):
s = lazystr('a&b')
b = lazybytes(b'a&b')
- self.assertIsInstance(mark_for_escaping(s), Promise)
- self.assertIsInstance(mark_for_escaping(b), Promise)
+ self.assertIsInstance(mark_for_escaping(s), EscapeData)
+ self.assertIsInstance(mark_for_escaping(b), EscapeData)
self.assertRenderEqual('{% autoescape off %}{{ s }}{% endautoescape %}', 'a&amp;b', s=mark_for_escaping(s))
-
- def test_regression_20296(self):
- s = mark_safe(translation.ugettext_lazy("username"))
- with translation.override('fr'):
- self.assertRenderEqual('{{ s }}', "nom d'utilisateur", s=s)