[1.2.X] Backport of r14547 from trunk.
Fixed a test case that was failing in Oracle due to conflation of null and empty strings. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14550 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8c7df2198a
commit
17bd39ae5a
@ -28,13 +28,7 @@ class Stuff(models.Model):
|
|||||||
owner = models.ForeignKey(User, null=True)
|
owner = models.ForeignKey(User, null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
# Oracle doesn't distinguish between None and the empty string.
|
return unicode(self.name) + u' is owned by ' + unicode(self.owner)
|
||||||
# This hack makes the test case pass using Oracle.
|
|
||||||
name = self.name
|
|
||||||
if (settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] == 'django.db.backends.oracle'
|
|
||||||
and name == u''):
|
|
||||||
name = None
|
|
||||||
return unicode(name) + u' is owned by ' + unicode(self.owner)
|
|
||||||
|
|
||||||
|
|
||||||
class Absolute(models.Model):
|
class Absolute(models.Model):
|
||||||
|
@ -7,11 +7,12 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.core import management
|
from django.core import management
|
||||||
from django.core.management.commands.dumpdata import sort_dependencies
|
from django.core.management.commands.dumpdata import sort_dependencies
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
from django.db.models import signals
|
from django.db.models import signals
|
||||||
from django.db import transaction
|
from django.db import DEFAULT_DB_ALIAS, transaction
|
||||||
from django.test import TestCase, TransactionTestCase
|
from django.test import TestCase, TransactionTestCase
|
||||||
|
|
||||||
from models import Animal, Stuff
|
from models import Animal, Stuff
|
||||||
@ -58,22 +59,39 @@ class TestFixtures(TestCase):
|
|||||||
weight=2.2
|
weight=2.2
|
||||||
)
|
)
|
||||||
animal.save()
|
animal.save()
|
||||||
self.assertGreater(animal.id, 1)
|
self.assertTrue(animal.id > 1)
|
||||||
|
|
||||||
def test_pretty_print_xml(self):
|
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] != 'django.db.backends.oracle':
|
||||||
"""
|
def test_pretty_print_xml(self):
|
||||||
Regression test for ticket #4558 -- pretty printing of XML fixtures
|
"""
|
||||||
doesn't affect parsing of None values.
|
Regression test for ticket #4558 -- pretty printing of XML fixtures
|
||||||
"""
|
doesn't affect parsing of None values.
|
||||||
# Load a pretty-printed XML fixture with Nulls.
|
"""
|
||||||
management.call_command(
|
# Load a pretty-printed XML fixture with Nulls.
|
||||||
'loaddata',
|
management.call_command(
|
||||||
'pretty.xml',
|
'loaddata',
|
||||||
verbosity=0,
|
'pretty.xml',
|
||||||
commit=False
|
verbosity=0,
|
||||||
)
|
commit=False
|
||||||
self.assertEqual(Stuff.objects.all()[0].name, None)
|
)
|
||||||
self.assertEqual(Stuff.objects.all()[0].owner, None)
|
self.assertEqual(Stuff.objects.all()[0].name, None)
|
||||||
|
self.assertEqual(Stuff.objects.all()[0].owner, None)
|
||||||
|
|
||||||
|
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'] == 'django.db.backends.oracle':
|
||||||
|
def test_pretty_print_xml_empty_strings(self):
|
||||||
|
"""
|
||||||
|
Regression test for ticket #4558 -- pretty printing of XML fixtures
|
||||||
|
doesn't affect parsing of None values.
|
||||||
|
"""
|
||||||
|
# Load a pretty-printed XML fixture with Nulls.
|
||||||
|
management.call_command(
|
||||||
|
'loaddata',
|
||||||
|
'pretty.xml',
|
||||||
|
verbosity=0,
|
||||||
|
commit=False
|
||||||
|
)
|
||||||
|
self.assertEqual(Stuff.objects.all()[0].name, u'')
|
||||||
|
self.assertEqual(Stuff.objects.all()[0].owner, None)
|
||||||
|
|
||||||
def test_absolute_path(self):
|
def test_absolute_path(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user