Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Fixed templates tests.

  • Loading branch information...
commit 6cb76cb140d8ca9815fc90829b6636eb6e43ac42 1 parent 4da1d0f
@aaugustin aaugustin authored
View
2  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'&']"),
+ 'filter-make_list02': ("{{ a|make_list }}", {"a": mark_safe("&")}, str_prefix("[%(_)s'&']")),
'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'&']")),
View
11 tests/regressiontests/templates/tests.py
@@ -27,6 +27,7 @@
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 @@ def b(self):
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 @@ def get_template_tests(self):
'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'),
Please sign in to comment.
Something went wrong with that request. Please try again.