summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-08-18 10:18:24 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-18 10:18:24 +0200
commit6cb76cb140d8ca9815fc90829b6636eb6e43ac42 (patch)
treedfef8aca8db99498f0a03f496120982d1219e292
parent4da1d0fd65e01abe013e0d5a9174b81c6bbfa677 (diff)
[py3] Fixed templates tests.
-rw-r--r--tests/regressiontests/templates/filters.py2
-rw-r--r--tests/regressiontests/templates/tests.py11
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py
index 606282ecc5..8b4aebbf22 100644
--- a/tests/regressiontests/templates/filters.py
+++ b/tests/regressiontests/templates/filters.py
@@ -114,7 +114,7 @@ def get_filter_tests():
# The make_list filter can destroy existing escaping, so the results are
# escaped.
'filter-make_list01': ("{% autoescape off %}{{ a|make_list }}{% endautoescape %}", {"a": mark_safe("&")}, str_prefix("[%(_)s'&']")),
- 'filter-make_list02': ("{{ a|make_list }}", {"a": mark_safe("&")}, "[u&#39;&amp;&#39;]"),
+ 'filter-make_list02': ("{{ a|make_list }}", {"a": mark_safe("&")}, str_prefix("[%(_)s&#39;&amp;&#39;]")),
'filter-make_list03': ('{% autoescape off %}{{ a|make_list|stringformat:"s"|safe }}{% endautoescape %}', {"a": mark_safe("&")}, str_prefix("[%(_)s'&']")),
'filter-make_list04': ('{{ a|make_list|stringformat:"s"|safe }}', {"a": mark_safe("&")}, str_prefix("[%(_)s'&']")),
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index a3be96cd62..41f40e7467 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -27,6 +27,7 @@ from django.test import RequestFactory
from django.test.utils import (setup_test_template_loader,
restore_template_loaders, override_settings)
from django.utils import unittest
+from django.utils.encoding import python_2_unicode_compatible
from django.utils.formats import date_format
from django.utils.translation import activate, deactivate, ugettext as _
from django.utils.safestring import mark_safe
@@ -148,10 +149,11 @@ class SilentAttrClass(object):
raise SomeException
b = property(b)
+@python_2_unicode_compatible
class UTF8Class:
- "Class whose __str__ returns non-ASCII data"
+ "Class whose __str__ returns non-ASCII data on Python 2"
def __str__(self):
- return 'ŠĐĆŽćžšđ'.encode('utf-8')
+ return 'ŠĐĆŽćžšđ'
class Templates(unittest.TestCase):
def setUp(self):
@@ -1451,8 +1453,9 @@ class Templates(unittest.TestCase):
'widthratio04': ('{% widthratio a b 100 %}', {'a':50,'b':100}, '50'),
'widthratio05': ('{% widthratio a b 100 %}', {'a':100,'b':100}, '100'),
- # 62.5 should round to 63
- 'widthratio06': ('{% widthratio a b 100 %}', {'a':50,'b':80}, '63'),
+ # 62.5 should round to 63 on Python 2 and 62 on Python 3
+ # See http://docs.python.org/py3k/whatsnew/3.0.html
+ 'widthratio06': ('{% widthratio a b 100 %}', {'a':50,'b':80}, '62' if six.PY3 else '63'),
# 71.4 should round to 71
'widthratio07': ('{% widthratio a b 100 %}', {'a':50,'b':70}, '71'),