Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed a test case that was failing in Oracle due to conflation of nul…

…l and empty strings.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14547 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8a7a44ffa2c1c860b80dee8c2c1d0c2442fcd4f8 1 parent 9892f4c
Ian Kelly authored
8  tests/regressiontests/fixtures_regress/models.py
@@ -28,13 +28,7 @@ class Stuff(models.Model):
28 28
     owner = models.ForeignKey(User, null=True)
29 29
 
30 30
     def __unicode__(self):
31  
-        # Oracle doesn't distinguish between None and the empty string.
32  
-        # This hack makes the test case pass using Oracle.
33  
-        name = self.name
34  
-        if (connection.features.interprets_empty_strings_as_nulls
35  
-            and name == u''):
36  
-            name = None
37  
-        return unicode(name) + u' is owned by ' + unicode(self.owner)
  31
+        return unicode(self.name) + u' is owned by ' + unicode(self.owner)
38 32
 
39 33
 
40 34
 class Absolute(models.Model):
20  tests/regressiontests/fixtures_regress/tests.py
@@ -13,7 +13,8 @@
13 13
 from django.core.management.base import CommandError
14 14
 from django.db.models import signals
15 15
 from django.db import transaction
16  
-from django.test import TestCase, TransactionTestCase
  16
+from django.test import TestCase, TransactionTestCase, skipIfDBFeature, \
  17
+    skipUnlessDBFeature
17 18
 
18 19
 from models import Animal, Stuff
19 20
 from models import Absolute, Parent, Child
@@ -61,6 +62,7 @@ def test_duplicate_pk(self):
61 62
         animal.save()
62 63
         self.assertGreater(animal.id, 1)
63 64
 
  65
+    @skipIfDBFeature('interprets_empty_strings_as_nulls')
64 66
     def test_pretty_print_xml(self):
65 67
         """
66 68
         Regression test for ticket #4558 -- pretty printing of XML fixtures
@@ -76,6 +78,22 @@ def test_pretty_print_xml(self):
76 78
         self.assertEqual(Stuff.objects.all()[0].name, None)
77 79
         self.assertEqual(Stuff.objects.all()[0].owner, None)
78 80
 
  81
+    @skipUnlessDBFeature('interprets_empty_strings_as_nulls')
  82
+    def test_pretty_print_xml_empty_strings(self):
  83
+        """
  84
+        Regression test for ticket #4558 -- pretty printing of XML fixtures
  85
+        doesn't affect parsing of None values.
  86
+        """
  87
+        # Load a pretty-printed XML fixture with Nulls.
  88
+        management.call_command(
  89
+            'loaddata',
  90
+            'pretty.xml',
  91
+            verbosity=0,
  92
+            commit=False
  93
+        )
  94
+        self.assertEqual(Stuff.objects.all()[0].name, u'')
  95
+        self.assertEqual(Stuff.objects.all()[0].owner, None)
  96
+
79 97
     def test_absolute_path(self):
80 98
         """
81 99
         Regression test for ticket #6436 --

0 notes on commit 8a7a44f

Please sign in to comment.
Something went wrong with that request. Please try again.