[1.1.X] Made a few Python 2.3 compatibility test fixes.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12716 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey 2010-03-08 04:37:45 +00:00
parent 1adc88f4b4
commit 9b2ac2ad2d
3 changed files with 15 additions and 15 deletions

View File

@ -6,16 +6,16 @@ from models import DataModel
class CustomField(TestCase):
def test_defer(self):
d = DataModel.objects.create(data=[1, 2, 3])
self.assertTrue(isinstance(d.data, list))
self.failUnless(isinstance(d.data, list))
d = DataModel.objects.get(pk=d.pk)
self.assertTrue(isinstance(d.data, list))
self.failUnless(isinstance(d.data, list))
self.assertEqual(d.data, [1, 2, 3])
d = DataModel.objects.defer("data").get(pk=d.pk)
d.save()
d = DataModel.objects.get(pk=d.pk)
self.assertTrue(isinstance(d.data, list))
self.failUnless(isinstance(d.data, list))
self.assertEqual(d.data, [1, 2, 3])

View File

@ -112,8 +112,8 @@ BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T
>>> email.encoding = 'iso-8859-1'
>>> email.message()['To']
'=?iso-8859-1?q?S=FCrname=2C_Firstname?= <to@example.com>, other@example.com'
>>> email.message()['Subject'].encode()
u'=?iso-8859-1?q?Message_from_Firstname_S=FCrname?='
>>> email.message()['Subject'].encode() == u'=?iso-8859-1?q?Message_from_Firstname_S=FCrname?='
True
# Make sure headers can be set with a different encoding than utf-8 in SafeMIMEMultipart as well
>>> headers = {"Date": "Fri, 09 Nov 2001 01:08:47 -0000", "Message-ID": "foo"}
@ -125,8 +125,8 @@ u'=?iso-8859-1?q?Message_from_Firstname_S=FCrname?='
>>> msg.encoding = 'iso-8859-1'
>>> msg.message()['To']
'=?iso-8859-1?q?S=FCrname=2C_Firstname?= <to@example.com>'
>>> msg.message()['Subject'].encode()
u'=?iso-8859-1?q?Message_from_Firstname_S=FCrname?='
>>> msg.message()['Subject'].encode() == u'=?iso-8859-1?q?Message_from_Firstname_S=FCrname?='
True
# Regression for #12791 - Encode body correctly with other encodings than utf-8
>>> email = EmailMessage('Subject', 'Firstname Sürname is a great guy.', 'from@example.com', ['other@example.com'])

View File

@ -35,10 +35,10 @@ class BasicFieldTests(django.test.TestCase):
choices = [(0, 0), (1, 1)]
model_field = models.Field(choices=choices)
form_field = model_field.formfield(show_hidden_initial=True)
self.assertTrue(form_field.show_hidden_initial)
self.failUnless(form_field.show_hidden_initial)
form_field = model_field.formfield(show_hidden_initial=False)
self.assertFalse(form_field.show_hidden_initial)
self.failIf(form_field.show_hidden_initial)
class DecimalFieldTests(django.test.TestCase):
def test_to_python(self):
@ -168,7 +168,7 @@ class TypeCoercionTests(django.test.TestCase):
"""
def test_lookup_integer_in_charfield(self):
self.assertEquals(Post.objects.filter(title=9).count(), 0)
def test_lookup_integer_in_textfield(self):
self.assertEquals(Post.objects.filter(body=24).count(), 0)