summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-02-07 09:17:38 +0100
committerClaude Paroz <claude@2xlibre.net>2017-02-07 17:14:02 +0100
commit3a148f958dddd97c1379081118c30fbede6b6bc4 (patch)
treec80d2aedaac8311898d1e7557623b7a0758ec6dd /tests
parent854f6950149e84d4c4bcbe98b7459084b44a6b9a (diff)
Refs #27795 -- Removed force_text from the template layer
Thanks Tim Graham for the review.
Diffstat (limited to 'tests')
-rw-r--r--tests/signing/tests.py4
-rw-r--r--tests/template_tests/syntax_tests/i18n/test_blocktrans.py6
-rw-r--r--tests/template_tests/test_unicode.py31
3 files changed, 5 insertions, 36 deletions
diff --git a/tests/signing/tests.py b/tests/signing/tests.py
index 01dd55fcfe..5969e3cc1c 100644
--- a/tests/signing/tests.py
+++ b/tests/signing/tests.py
@@ -18,7 +18,7 @@ class TestSigner(SimpleTestCase):
):
self.assertEqual(
signer.signature(s),
- signing.base64_hmac(signer.salt + 'signer', s, 'predictable-secret').decode()
+ signing.base64_hmac(signer.salt + 'signer', s, 'predictable-secret')
)
self.assertNotEqual(signer.signature(s), signer2.signature(s))
@@ -27,7 +27,7 @@ class TestSigner(SimpleTestCase):
signer = signing.Signer('predictable-secret', salt='extra-salt')
self.assertEqual(
signer.signature('hello'),
- signing.base64_hmac('extra-salt' + 'signer', 'hello', 'predictable-secret').decode()
+ signing.base64_hmac('extra-salt' + 'signer', 'hello', 'predictable-secret')
)
self.assertNotEqual(
signing.Signer('predictable-secret', salt='one').signature('hello'),
diff --git a/tests/template_tests/syntax_tests/i18n/test_blocktrans.py b/tests/template_tests/syntax_tests/i18n/test_blocktrans.py
index 9af60e5131..d8b1e807af 100644
--- a/tests/template_tests/syntax_tests/i18n/test_blocktrans.py
+++ b/tests/template_tests/syntax_tests/i18n/test_blocktrans.py
@@ -17,20 +17,20 @@ class I18nBlockTransTagTests(SimpleTestCase):
@setup({'i18n03': '{% load i18n %}{% blocktrans %}{{ anton }}{% endblocktrans %}'})
def test_i18n03(self):
"""simple translation of a variable"""
- output = self.engine.render_to_string('i18n03', {'anton': b'\xc3\x85'})
+ output = self.engine.render_to_string('i18n03', {'anton': 'Å'})
self.assertEqual(output, 'Å')
@setup({'i18n04': '{% load i18n %}{% blocktrans with berta=anton|lower %}{{ berta }}{% endblocktrans %}'})
def test_i18n04(self):
"""simple translation of a variable and filter"""
- output = self.engine.render_to_string('i18n04', {'anton': b'\xc3\x85'})
+ output = self.engine.render_to_string('i18n04', {'anton': 'Å'})
self.assertEqual(output, 'å')
@setup({'legacyi18n04': '{% load i18n %}'
'{% blocktrans with anton|lower as berta %}{{ berta }}{% endblocktrans %}'})
def test_legacyi18n04(self):
"""simple translation of a variable and filter"""
- output = self.engine.render_to_string('legacyi18n04', {'anton': b'\xc3\x85'})
+ output = self.engine.render_to_string('legacyi18n04', {'anton': 'Å'})
self.assertEqual(output, 'å')
@setup({'i18n05': '{% load i18n %}{% blocktrans %}xxx{{ anton }}xxx{% endblocktrans %}'})
diff --git a/tests/template_tests/test_unicode.py b/tests/template_tests/test_unicode.py
deleted file mode 100644
index 42682166f5..0000000000
--- a/tests/template_tests/test_unicode.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from unittest import TestCase
-
-from django.template import Context, Engine
-from django.template.base import TemplateEncodingError
-from django.utils.safestring import SafeData
-
-
-class UnicodeTests(TestCase):
- def test_template(self):
- # Templates can be created from strings.
- engine = Engine()
- t1 = engine.from_string('ŠĐĆŽćžšđ {{ var }}')
- # Templates can also be created from bytestrings. These are assumed to
- # be encoded using UTF-8.
- s = b'\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91 {{ var }}'
- t2 = engine.from_string(s)
- with self.assertRaises(TemplateEncodingError):
- engine.from_string(b'\x80\xc5\xc0')
-
- # Contexts can be constructed from strings or UTF-8 bytestrings.
- Context({b"var": b"foo"})
- Context({"var": b"foo"})
- c3 = Context({b"var": "Đđ"})
- Context({"var": b"\xc4\x90\xc4\x91"})
-
- # Since both templates and all four contexts represent the same thing,
- # they all render the same (and are returned as strings and
- # "safe" objects as well, for auto-escaping purposes).
- self.assertEqual(t1.render(c3), t2.render(c3))
- self.assertIsInstance(t1.render(c3), str)
- self.assertIsInstance(t1.render(c3), SafeData)