summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Kelly <ian.g.kelly@gmail.com>2010-11-12 19:26:57 +0000
committerIan Kelly <ian.g.kelly@gmail.com>2010-11-12 19:26:57 +0000
commit8a7a44ffa2c1c860b80dee8c2c1d0c2442fcd4f8 (patch)
tree5ce666bc216c4fcf52f3cc80a78e041759797736
parent9892f4c5d58857c3fbbf45394b13c7bc0fce5161 (diff)
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/trunk@14547 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/regressiontests/fixtures_regress/models.py8
-rw-r--r--tests/regressiontests/fixtures_regress/tests.py20
2 files changed, 20 insertions, 8 deletions
diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py
index 8736346a66..2dfb55035a 100644
--- a/tests/regressiontests/fixtures_regress/models.py
+++ b/tests/regressiontests/fixtures_regress/models.py
@@ -28,13 +28,7 @@ class Stuff(models.Model):
owner = models.ForeignKey(User, null=True)
def __unicode__(self):
- # Oracle doesn't distinguish between None and the empty string.
- # This hack makes the test case pass using Oracle.
- name = self.name
- if (connection.features.interprets_empty_strings_as_nulls
- and name == u''):
- name = None
- return unicode(name) + u' is owned by ' + unicode(self.owner)
+ return unicode(self.name) + u' is owned by ' + unicode(self.owner)
class Absolute(models.Model):
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 5b27c3405d..8e998e95ce 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -13,7 +13,8 @@ from django.core.management.commands.dumpdata import sort_dependencies
from django.core.management.base import CommandError
from django.db.models import signals
from django.db import transaction
-from django.test import TestCase, TransactionTestCase
+from django.test import TestCase, TransactionTestCase, skipIfDBFeature, \
+ skipUnlessDBFeature
from models import Animal, Stuff
from models import Absolute, Parent, Child
@@ -61,6 +62,7 @@ class TestFixtures(TestCase):
animal.save()
self.assertGreater(animal.id, 1)
+ @skipIfDBFeature('interprets_empty_strings_as_nulls')
def test_pretty_print_xml(self):
"""
Regression test for ticket #4558 -- pretty printing of XML fixtures
@@ -76,6 +78,22 @@ class TestFixtures(TestCase):
self.assertEqual(Stuff.objects.all()[0].name, None)
self.assertEqual(Stuff.objects.all()[0].owner, None)
+ @skipUnlessDBFeature('interprets_empty_strings_as_nulls')
+ 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):
"""
Regression test for ticket #6436 --