summaryrefslogtreecommitdiff
path: root/tests/regressiontests/model_forms_regress
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests/model_forms_regress')
-rw-r--r--tests/regressiontests/model_forms_regress/models.py4
-rw-r--r--tests/regressiontests/model_forms_regress/tests.py20
2 files changed, 13 insertions, 11 deletions
diff --git a/tests/regressiontests/model_forms_regress/models.py b/tests/regressiontests/model_forms_regress/models.py
index d070a9be75..9259e260f0 100644
--- a/tests/regressiontests/model_forms_regress/models.py
+++ b/tests/regressiontests/model_forms_regress/models.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
import os
from django.core.exceptions import ValidationError
@@ -13,7 +15,7 @@ class Triple(models.Model):
right = models.IntegerField()
class Meta:
- unique_together = (('left', 'middle'), (u'middle', u'right'))
+ unique_together = (('left', 'middle'), ('middle', 'right'))
class FilePathModel(models.Model):
path = models.FilePathField(path=os.path.dirname(__file__), match=".*\.py$", blank=True)
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index d33f52af9a..a0f9bba170 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+from __future__ import absolute_import, unicode_literals
from datetime import date
@@ -134,7 +134,7 @@ class ManyToManyCallableInitialTests(TestCase):
# Create a ModelForm, instantiate it, and check that the output is as expected
ModelForm = modelform_factory(Article, formfield_callback=formfield_for_dbfield)
form = ModelForm()
- self.assertHTMLEqual(form.as_ul(), u"""<li><label for="id_headline">Headline:</label> <input id="id_headline" type="text" name="headline" maxlength="100" /></li>
+ self.assertHTMLEqual(form.as_ul(), """<li><label for="id_headline">Headline:</label> <input id="id_headline" type="text" name="headline" maxlength="100" /></li>
<li><label for="id_publications">Publications:</label> <select multiple="multiple" name="publications" id="id_publications">
<option value="%d" selected="selected">First Book</option>
<option value="%d" selected="selected">Second Book</option>
@@ -194,7 +194,7 @@ class OneToOneFieldTests(TestCase):
publication = Publication.objects.create(title="Pravda",
date_published=date(1991, 8, 22))
author = Author.objects.create(publication=publication, full_name='John Doe')
- form = AuthorForm({'publication':u'', 'full_name':'John Doe'}, instance=author)
+ form = AuthorForm({'publication':'', 'full_name':'John Doe'}, instance=author)
self.assertTrue(form.is_valid())
self.assertEqual(form.cleaned_data['publication'], None)
author = form.save()
@@ -212,7 +212,7 @@ class OneToOneFieldTests(TestCase):
publication = Publication.objects.create(title="Pravda",
date_published=date(1991, 8, 22))
author = Author1.objects.create(publication=publication, full_name='John Doe')
- form = AuthorForm({'publication':u'', 'full_name':'John Doe'}, instance=author)
+ form = AuthorForm({'publication':'', 'full_name':'John Doe'}, instance=author)
self.assertTrue(not form.is_valid())
@@ -419,7 +419,7 @@ class FileFieldTests(unittest.TestCase):
data={'myfile-clear': 'true'})
self.assertTrue(not form.is_valid())
self.assertEqual(form.errors['myfile'],
- [u'Please either submit a file or check the clear checkbox, not both.'])
+ ['Please either submit a file or check the clear checkbox, not both.'])
rendered = unicode(form)
self.assertTrue('something.txt' in rendered)
self.assertTrue('myfile-clear' in rendered)
@@ -435,8 +435,8 @@ class EditionForm(forms.ModelForm):
class UniqueErrorsTests(TestCase):
def setUp(self):
- self.author1 = Person.objects.create(name=u'Author #1')
- self.author2 = Person.objects.create(name=u'Author #2')
+ self.author1 = Person.objects.create(name='Author #1')
+ self.author2 = Person.objects.create(name='Author #2')
self.pub1 = Publication.objects.create(title='Pub #1', date_published=date(2000, 10, 31))
self.pub2 = Publication.objects.create(title='Pub #2', date_published=date(2004, 1, 5))
form = EditionForm(data={'author': self.author1.pk, 'publication': self.pub1.pk, 'edition': 1, 'isbn': '9783161484100'})
@@ -444,13 +444,13 @@ class UniqueErrorsTests(TestCase):
def test_unique_error_message(self):
form = EditionForm(data={'author': self.author1.pk, 'publication': self.pub2.pk, 'edition': 1, 'isbn': '9783161484100'})
- self.assertEqual(form.errors, {'isbn': [u'Edition with this Isbn already exists.']})
+ self.assertEqual(form.errors, {'isbn': ['Edition with this Isbn already exists.']})
def test_unique_together_error_message(self):
form = EditionForm(data={'author': self.author1.pk, 'publication': self.pub1.pk, 'edition': 2, 'isbn': '9783161489999'})
- self.assertEqual(form.errors, {'__all__': [u'Edition with this Author and Publication already exists.']})
+ self.assertEqual(form.errors, {'__all__': ['Edition with this Author and Publication already exists.']})
form = EditionForm(data={'author': self.author2.pk, 'publication': self.pub1.pk, 'edition': 1, 'isbn': '9783161487777'})
- self.assertEqual(form.errors, {'__all__': [u'Edition with this Publication and Edition already exists.']})
+ self.assertEqual(form.errors, {'__all__': ['Edition with this Publication and Edition already exists.']})
class EmptyFieldsTestCase(TestCase):