mirror of
https://github.com/django/django.git
synced 2025-10-27 23:56:08 +00:00
Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and Jannis Leidel for the review.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
@@ -83,7 +83,7 @@ class PerformUniqueChecksTest(TestCase):
|
||||
p = Post(title="Django 1.0 is released", posted=datetime.date(2008, 9, 3))
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
p.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'title': [u'Title must be unique for Posted date.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'title': ['Title must be unique for Posted date.']})
|
||||
|
||||
# Should work without errors
|
||||
p = Post(title="Work on Django 1.1 begins", posted=datetime.date(2008, 9, 3))
|
||||
@@ -96,17 +96,17 @@ class PerformUniqueChecksTest(TestCase):
|
||||
p = Post(slug="Django 1.0", posted=datetime.datetime(2008, 1, 1))
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
p.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'slug': [u'Slug must be unique for Posted year.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'slug': ['Slug must be unique for Posted year.']})
|
||||
|
||||
p = Post(subtitle="Finally", posted=datetime.datetime(2008, 9, 30))
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
p.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'subtitle': [u'Subtitle must be unique for Posted month.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'subtitle': ['Subtitle must be unique for Posted month.']})
|
||||
|
||||
p = Post(title="Django 1.0 is released")
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
p.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'posted': [u'This field cannot be null.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'posted': ['This field cannot be null.']})
|
||||
|
||||
def test_unique_for_date_with_nullable_date(self):
|
||||
p1 = FlexibleDatePost.objects.create(title="Django 1.0 is released",
|
||||
@@ -135,10 +135,10 @@ class PerformUniqueChecksTest(TestCase):
|
||||
m = UniqueErrorsModel(name='Some Name', no=11)
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
m.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'name': [u'Custom unique name message.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'name': ['Custom unique name message.']})
|
||||
|
||||
m = UniqueErrorsModel(name='Some Other Name', no=10)
|
||||
with self.assertRaises(ValidationError) as cm:
|
||||
m.full_clean()
|
||||
self.assertEqual(cm.exception.message_dict, {'no': [u'Custom unique number message.']})
|
||||
self.assertEqual(cm.exception.message_dict, {'no': ['Custom unique number message.']})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user