From bdca5ea345c548a82a80d198906818c9ccbef896 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 20 Jul 2012 14:48:51 +0200 Subject: [py3] Replaced unicode/str by six.text_type/bytes. --- tests/regressiontests/forms/tests/models.py | 3 ++- tests/regressiontests/forms/tests/util.py | 3 ++- tests/regressiontests/forms/tests/widgets.py | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/regressiontests/forms') diff --git a/tests/regressiontests/forms/tests/models.py b/tests/regressiontests/forms/tests/models.py index 5bea49b840..7687335b48 100644 --- a/tests/regressiontests/forms/tests/models.py +++ b/tests/regressiontests/forms/tests/models.py @@ -8,6 +8,7 @@ from django.db import models from django.forms import Form, ModelForm, FileField, ModelChoiceField from django.forms.models import ModelFormMetaclass from django.test import TestCase +from django.utils import six from ..models import (ChoiceOptionModel, ChoiceFieldModel, FileModel, Group, BoundaryModel, Defaults) @@ -40,7 +41,7 @@ class ModelFormCallableModelDefault(TestCase): choices = list(ChoiceFieldForm().fields['choice'].choices) self.assertEqual(len(choices), 1) - self.assertEqual(choices[0], (option.pk, unicode(option))) + self.assertEqual(choices[0], (option.pk, six.text_type(option))) def test_callable_initial_value(self): "The initial value for a callable default returning a queryset is the pk (refs #13769)" diff --git a/tests/regressiontests/forms/tests/util.py b/tests/regressiontests/forms/tests/util.py index 280049c97b..b7cc4ec809 100644 --- a/tests/regressiontests/forms/tests/util.py +++ b/tests/regressiontests/forms/tests/util.py @@ -5,6 +5,7 @@ from django.core.exceptions import ValidationError from django.forms.util import flatatt, ErrorDict, ErrorList from django.test import TestCase from django.utils.safestring import mark_safe +from django.utils import six from django.utils.translation import ugettext_lazy @@ -30,7 +31,7 @@ class FormsUtilTestCase(TestCase): '') # Can take a unicode string. - self.assertHTMLEqual(unicode(ErrorList(ValidationError("Not \u03C0.").messages)), + self.assertHTMLEqual(six.text_type(ErrorList(ValidationError("Not \u03C0.").messages)), '') # Can take a lazy string. diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py index d5f6334fe9..3ea42cf549 100644 --- a/tests/regressiontests/forms/tests/widgets.py +++ b/tests/regressiontests/forms/tests/widgets.py @@ -10,6 +10,7 @@ from django.forms import * from django.forms.widgets import RadioFieldRenderer from django.utils import formats from django.utils.safestring import mark_safe +from django.utils import six from django.utils.translation import activate, deactivate from django.test import TestCase @@ -676,7 +677,7 @@ beatle J R Ringo False""") # You can create your own custom renderers for RadioSelect to use. class MyRenderer(RadioFieldRenderer): def render(self): - return '
\n'.join([unicode(choice) for choice in self]) + return '
\n'.join([six.text_type(choice) for choice in self]) w = RadioSelect(renderer=MyRenderer) self.assertHTMLEqual(w.render('beatle', 'G', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))), """

@@ -716,7 +717,7 @@ beatle J R Ringo False""") # Unicode choices are correctly rendered as HTML w = RadioSelect() - self.assertHTMLEqual(unicode(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')])), '') + self.assertHTMLEqual(six.text_type(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')])), '') # Attributes provided at instantiation are passed to the constituent inputs w = RadioSelect(attrs={'id':'foo'}) @@ -1135,7 +1136,7 @@ class ClearableFileInputTests(TestCase): output = widget.render('my
file', field) self.assertFalse(field.url in output) self.assertTrue('href="something?chapter=1&sect=2&copy=3&lang=en"' in output) - self.assertFalse(unicode(field) in output) + self.assertFalse(six.text_type(field) in output) self.assertTrue('something<div onclick="alert('oops')">.jpg' in output) self.assertTrue('my<div>file' in output) self.assertFalse('my
file' in output) -- cgit v1.3