Commits

Anonymous committed 5883a6d

* Re-enabled slicing/relation test for Bug26
* doctests now use direct .save()'s instead of temp objects.

Comments (0)

Files changed (3)

tests/test_main/nulls/models.py

 
 class TableNullChar(BaseModel):
     """
-    >>> obj = TableNullChar(val=None)
-    >>> obj.save()
-    >>> obj = TableNullChar(val="This is my string value.")
-    >>> obj.save()
+    >>> TableNullChar(val=None).save()
+    >>> TableNullChar(val="This is my string value.").save()
     >>> len(list(TableNullChar.objects.all()))
     2
     """
     
 class TableNullText(BaseModel):
     """
-    >>> obj = TableNullText(val=None)
-    >>> obj.save()
-    >>> obj = TableNullText(val="This is my string value.")
-    >>> obj.save()
+    >>> TableNullText(val=None).save()
+    >>> TableNullText(val="This is my string value.").save()
     >>> len(list(TableNullText.objects.all()))
     2
     """
 
 class TableNullInteger(BaseModel):
     """
-    >>> obj = TableNullInteger(val=None)
-    >>> obj.save()
-    >>> obj = TableNullInteger(val=39482)
-    >>> obj.save()
+    >>> TableNullInteger(val=None).save()
+    >>> TableNullInteger(val=39482).save()
     >>> len(list(TableNullInteger.objects.all()))
     2
     """
 
 class TableNullDateTime(BaseModel):
     """
-    >>> obj = TableNullDateTime(val=None)
-    >>> obj.save()
-    >>> obj = TableNullDateTime(val=datetime.datetime(2009,1,1,4,3,5))
-    >>> obj.save()
+    >>> TableNullDateTime(val=None).save()
+    >>> TableNullDateTime(val=datetime.datetime(2009,1,1,4,3,5)).save()
     >>> len(list(TableNullDateTime.objects.all()))
     2
     """
 
 class TableNullDate(BaseModel):
     """
-    >>> obj = TableNullDate(val=None)
-    >>> obj.save()
-    >>> obj = TableNullDate(val=datetime.date(2009,1,1))
-    >>> obj.save()
+    >>> TableNullDate(val=None).save()
+    >>> TableNullDate(val=datetime.date(2009,1,1)).save()
     >>> len(list(TableNullDate.objects.all()))
     2
     """
     This test isn't expected to work on SQL Server 2005,
     as there is no bare "time" type.
     
-    obj = TableNullTime(val=None)
-    obj.save()
-    obj = TableNullTime(val=datetime.time(2,34,2))
-    obj.save()
+    TableNullTime(val=None).save()
+    TableNullTime(val=datetime.time(2,34,2)).save()
     len(list(TableNullTime.objects.all()))
     2
     """
 
 class TableNullBoolean(BaseModel):
     """
-    >>> obj = TableNullBoolean(val=None)
-    >>> obj.save()
-    >>> obj = TableNullBoolean(val=True)
-    >>> obj.save()
-    >>> obj = TableNullBoolean(val=False)
-    >>> obj.save()
+    >>> TableNullBoolean(val=None).save()
+    >>> TableNullBoolean(val=True).save()
+    >>> TableNullBoolean(val=False).save()
     >>> len(list(TableNullBoolean.objects.all()))
     3
     """
 
 class TableNullNullBoolean(BaseModel):
     """
-    >>> obj = TableNullNullBoolean(val=None)
-    >>> obj.save()
-    >>> obj = TableNullNullBoolean(val=True)
-    >>> obj.save()
-    >>> obj = TableNullNullBoolean(val=False)
-    >>> obj.save()
+    >>> TableNullNullBoolean(val=None).save()
+    >>> TableNullNullBoolean(val=True).save()
+    >>> TableNullNullBoolean(val=False).save()
     >>> len(list(TableNullNullBoolean.objects.all()))
     3
     """
 
 class TableNullDecimal(BaseModel):
     """
-    >>> obj = TableNullDecimal(val=None)
-    >>> obj.save()
-    
+    >>> TableNullDecimal(val=None).save()
+   
     Try a value at the top end of the specified precision/scale
-    >>> obj = TableNullDecimal(val=decimal.Decimal('99.99'))
-    >>> obj.save()
+    >>> TableNullDecimal(val=decimal.Decimal('99.99')).save()
     
     >>> len(list(TableNullDecimal.objects.all()))
     2
 
 class TableNullFloat(BaseModel):
     """
-    >>> obj = TableNullFloat(val=None)
-    >>> obj.save()
-    >>> obj = TableNullFloat(val=34.3)
-    >>> obj.save()
+    >>> TableNullFloat(val=None).save()
+    >>> TableNullFloat(val=34.3).save()
     >>> len(list(TableNullFloat.objects.all()))
     2
     """

tests/test_main/regressiontests/models.py

 import datetime
 import decimal
 from django.db import models
-
-import unittest
+from django.test import TestCase
 
 class Bug19Table(models.Model):
     """ A simple model for testing string comparisons.
     """
     Test adding decimals as actual types or as strings.
     
-    >>> obj = Bug21Table(a='decimal as decimal', d=decimal.Decimal('12.34'))
-    >>> obj.save()
-    >>> obj = Bug21Table(a='decimal as string', d=u'56.78')
-    >>> obj.save()
+    >>> Bug21Table(a='decimal as decimal', d=decimal.Decimal('12.34')).save()
+    >>> Bug21Table(a='decimal as string', d=u'56.78').save()
     >>> len(list(Bug21Table.objects.all()))
     2
     """
 class Bug23Table(models.Model):
     """
     Test inserting mixed NULL and non-NULL values.
-    
-    >>> obj = Bug23Table(mycharfield1=None, mycharfield2="text2", myintfield=1)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1="text1", mycharfield2=None, myintfield=1)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1="text1", mycharfield2="text2", myintfield=None)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1=None, mycharfield2=None, myintfield=1)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1=None, mycharfield2="text2", myintfield=None)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1="text1", mycharfield2=None, myintfield=None)
-    >>> obj.save()
-    >>> obj = Bug23Table(mycharfield1=None, mycharfield2=None, myintfield=None)
-    >>> obj.save()
+
+    >>> Bug23Table(mycharfield1=None, mycharfield2="text2", myintfield=1).save()
+    >>> Bug23Table(mycharfield1="text1", mycharfield2=None, myintfield=1).save()
+    >>> Bug23Table(mycharfield1="text1", mycharfield2="text2", myintfield=None).save()
+    >>> Bug23Table(mycharfield1=None, mycharfield2=None, myintfield=1).save()
+    >>> Bug23Table(mycharfield1=None, mycharfield2="text2", myintfield=None).save()
+    >>> Bug23Table(mycharfield1="text1", mycharfield2=None, myintfield=None).save()
+    >>> Bug23Table(mycharfield1=None, mycharfield2=None, myintfield=None).save()
     >>> objs = list(Bug23Table.objects.all())
     >>> len(objs)
     7
     mycharfield2 = models.CharField(max_length=50, null=True)
     myintfield = models.IntegerField(null=True)
 
+
+# Bug 26 tables, RelatedA and RelatedB
 class RelatedB(models.Model):
     a = models.CharField(max_length=50)
     b = models.CharField(max_length=50)
     c = models.CharField(max_length=50)
 
-
 class RelatedA(models.Model):
-    """
-    #>>> b = RelatedB(a='this is a value', b="valueb", c="valuec")
-    #>>> b.save()
-    #>>> a = RelatedA(a="valuea", b=b)
-    #>>> a.save()
-    #>>> a = RelatedA(a="valuea", b=b)
-    #>>> a.save()
-    #>>> items = RelatedA.objects.select_related()[1:2]
-    #>>> len(items)
-    #1
-    """
     a = models.CharField(max_length=50)
     b = models.ForeignKey(RelatedB)
+
+class Bug26TestCase(TestCase):
+    """Test that slicing queries w/ duplicate column names works."""
+
+    def testWithDuplicateColumnNames(self):
+        b = RelatedB(a='this is a value', b="valueb", c="valuec")
+        b.save()
+        
+        RelatedA(a="valuea", b=b).save()
+        RelatedA(a="valuea", b=b).save()
+
+        items = RelatedA.objects.select_related()[1:2]
+        self.assertEqual(len(items), 1)

tests/test_main/slicing/models.py

 from django.db import models
 from django.core.paginator import Paginator
+from django.test import TestCase
 
-from django.test import TestCase
-#import unittest
 
 class FirstTable(models.Model):
     b = models.CharField(max_length=100)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.