summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-21 10:00:10 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-08-07 12:00:22 +0200
commitc5ef65bcf324f4c90b53be90f4aec069a68e8c59 (patch)
treebb9a4988fbae4e7366cc578ca845c49003cdcd64 /tests/regressiontests/forms
parentee191715eae73362768184aa95206cf61bac5d38 (diff)
[py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under Python 2 for backwards compatibility). * Renamed smart_str to smart_bytes. * Re-introduced smart_str as an alias for smart_text under Python 3 and smart_bytes under Python 2 (which is backwards compatible). Thus smart_str always returns a str objects. * Used the new smart_str in a few places where both Python 2 and 3 want a str.
Diffstat (limited to 'tests/regressiontests/forms')
-rw-r--r--tests/regressiontests/forms/tests/extra.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/regressiontests/forms/tests/extra.py b/tests/regressiontests/forms/tests/extra.py
index 28b6c12453..e0e62858d0 100644
--- a/tests/regressiontests/forms/tests/extra.py
+++ b/tests/regressiontests/forms/tests/extra.py
@@ -9,7 +9,7 @@ from django.forms.extras import SelectDateWidget
from django.forms.util import ErrorList
from django.test import TestCase
from django.utils import translation
-from django.utils.encoding import force_unicode, smart_unicode
+from django.utils.encoding import force_text, smart_text
from .error_messages import AssertFormErrorsMixin
@@ -551,7 +551,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
f = GenericIPAddressField(unpack_ipv4=True)
self.assertEqual(f.clean('::ffff:0a0a:0a0a'), '10.10.10.10')
- def test_smart_unicode(self):
+ def test_smart_text(self):
class Test:
def __str__(self):
return 'ŠĐĆŽćžšđ'.encode('utf-8')
@@ -562,10 +562,10 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
def __unicode__(self):
return '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111'
- self.assertEqual(smart_unicode(Test()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
- self.assertEqual(smart_unicode(TestU()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
- self.assertEqual(smart_unicode(1), '1')
- self.assertEqual(smart_unicode('foo'), 'foo')
+ self.assertEqual(smart_text(Test()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
+ self.assertEqual(smart_text(TestU()), '\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111')
+ self.assertEqual(smart_text(1), '1')
+ self.assertEqual(smart_text('foo'), 'foo')
def test_accessing_clean(self):
class UserForm(Form):
@@ -591,7 +591,7 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
def as_divs(self):
if not self: return ''
- return '<div class="errorlist">%s</div>' % ''.join(['<div class="error">%s</div>' % force_unicode(e) for e in self])
+ return '<div class="errorlist">%s</div>' % ''.join(['<div class="error">%s</div>' % force_text(e) for e in self])
class CommentForm(Form):
name = CharField(max_length=50, required=False)