Commits

Anonymous committed 7aaec98

Fixed a test case that was failing in Oracle due to conflation of null and empty strings.

  • Participants
  • Parent commits 6fea6c2

Comments (0)

Files changed (2)

File tests/regressiontests/fixtures_regress/models.py

     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):

File tests/regressiontests/fixtures_regress/tests.py

 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
         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
         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 --