diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-01-30 19:15:59 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-30 21:10:32 +0100 |
| commit | ccfd1295f986cdf628d774937d0b38a14584721f (patch) | |
| tree | c3d37f5fff520822674127940c37c42f09c821d0 /tests/utils_tests/test_safestring.py | |
| parent | 274ca999825bb782bbbddd769783cf2aa91de7f9 (diff) | |
Refs #27795 -- Prevented SafeText from losing safe status on str()
This will allow to replace force_text() by str() in several places (as one of
the features of force_text is to keep the safe status).
Diffstat (limited to 'tests/utils_tests/test_safestring.py')
| -rw-r--r-- | tests/utils_tests/test_safestring.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py index be20cea11e..bb4dfd1280 100644 --- a/tests/utils_tests/test_safestring.py +++ b/tests/utils_tests/test_safestring.py @@ -24,6 +24,13 @@ class SafeStringTest(SimpleTestCase): self.assertRenderEqual('{{ s }}', 'a&b', s=s) self.assertRenderEqual('{{ s|force_escape }}', 'a&b', s=s) + def test_mark_safe_str(self): + """ + Calling str() on a SafeText instance doesn't lose the safe status. + """ + s = mark_safe('a&b') + self.assertIsInstance(str(s), type(s)) + def test_mark_safe_object_implementing_dunder_html(self): e = customescape('<a&b>') s = mark_safe(e) |
