From 21a449168b6f9b0a4ec1589c0ebc5cf4ad6053cb Mon Sep 17 00:00:00 2001 From: Ian Kelly Date: Fri, 30 Sep 2011 21:40:56 +0000 Subject: [PATCH] Fixed #16645: fixed a broken test to work in Oracle. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16919 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/model_forms/tests.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/modeltests/model_forms/tests.py b/tests/modeltests/model_forms/tests.py index 09a9d3f591..0ad3e06264 100644 --- a/tests/modeltests/model_forms/tests.py +++ b/tests/modeltests/model_forms/tests.py @@ -8,6 +8,7 @@ from django import forms from django.test import TestCase from django.core.files.uploadedfile import SimpleUploadedFile from django.core.validators import ValidationError +from django.db import connection from django.forms.models import model_to_dict from django.utils.unittest import skipUnless @@ -1313,11 +1314,17 @@ class OldFormForXTests(TestCase): instance.delete() # Test the non-required ImageField + # Note: In Oracle, we expect a null ImageField to return u'' instead of + # None. + if connection.features.interprets_empty_strings_as_nulls: + expected_null_imagefield_repr = u'' + else: + expected_null_imagefield_repr = None f = OptionalImageFileForm(data={'description': u'Test'}) self.assertEqual(f.is_valid(), True) instance = f.save() - self.assertEqual(instance.image.name, None) + self.assertEqual(instance.image.name, expected_null_imagefield_repr) self.assertEqual(instance.width, None) self.assertEqual(instance.height, None)