Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3164 -- Added explicit ordering to basic model test, and revis…

…ed results to suit the explicit order. Thanks to Matt Boersma for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3a54d0cd5b2868771bdeabd17998d72084e0338e 1 parent 3f4d6a2
Russell Keith-Magee authored December 19, 2006

Showing 1 changed file with 9 additions and 6 deletions. Show diff stats Hide diff stats

  1. 15  tests/modeltests/basic/models.py
15  tests/modeltests/basic/models.py
@@ -10,6 +10,9 @@ class Article(models.Model):
10 10
     headline = models.CharField(maxlength=100, default='Default headline')
11 11
     pub_date = models.DateTimeField()
12 12
 
  13
+    class Meta:
  14
+        ordering = ('pub_date','headline')
  15
+        
13 16
     def __str__(self):
14 17
         return self.headline
15 18
 
@@ -245,7 +248,7 @@ def __str__(self):
245 248
 
246 249
 # Slices (without step) are lazy:
247 250
 >>> Article.objects.all()[0:5].filter()
248  
-[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>]
  251
+[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Article 6>, <Article: Default headline>]
249 252
 
250 253
 # Slicing again works:
251 254
 >>> Article.objects.all()[0:5][0:2]
@@ -253,17 +256,17 @@ def __str__(self):
253 256
 >>> Article.objects.all()[0:5][:2]
254 257
 [<Article: Area woman programs in Python>, <Article: Second article>]
255 258
 >>> Article.objects.all()[0:5][4:]
256  
-[<Article: Article 6>]
  259
+[<Article: Default headline>]
257 260
 >>> Article.objects.all()[0:5][5:]
258 261
 []
259 262
 
260 263
 # Some more tests!
261 264
 >>> Article.objects.all()[2:][0:2]
262  
-[<Article: Third article>, <Article: Fourth article>]
  265
+[<Article: Third article>, <Article: Article 6>]
263 266
 >>> Article.objects.all()[2:][:2]
264  
-[<Article: Third article>, <Article: Fourth article>]
  267
+[<Article: Third article>, <Article: Article 6>]
265 268
 >>> Article.objects.all()[2:][2:3]
266  
-[<Article: Article 6>]
  269
+[<Article: Default headline>]
267 270
 
268 271
 # Note that you can't use 'offset' without 'limit' (on some dbs), so this doesn't work:
269 272
 >>> Article.objects.all()[2:]
@@ -312,7 +315,7 @@ def __str__(self):
312 315
 
313 316
 # Bulk delete test: How many objects before and after the delete?
314 317
 >>> Article.objects.all()
315  
-[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Fourth article>, <Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Updated article 8>]
  318
+[<Article: Area woman programs in Python>, <Article: Second article>, <Article: Third article>, <Article: Article 6>, <Article: Default headline>, <Article: Fourth article>, <Article: Article 7>, <Article: Updated article 8>]
316 319
 >>> Article.objects.filter(id__lte=4).delete()
317 320
 >>> Article.objects.all()
318 321
 [<Article: Article 6>, <Article: Default headline>, <Article: Article 7>, <Article: Updated article 8>]

0 notes on commit 3a54d0c

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