Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7786 -- Removed some tests from running when using Python 2.3.

The problem being "hidden" here is not serious. It won't affect correct code
and only gives a different failure mode for incorrect code. The moral is: don't
write incorrect code.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7939 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 431206a2523c2d4ceddd710b3075567eea9b2176 1 parent 52fdedb
Malcolm Tredinnick authored July 16, 2008

Showing 1 changed file with 25 additions and 17 deletions. Show diff stats Hide diff stats

  1. 42  tests/regressiontests/queries/models.py
42  tests/regressiontests/queries/models.py
@@ -4,6 +4,7 @@
4 4
 
5 5
 import datetime
6 6
 import pickle
  7
+import sys
7 8
 
8 9
 from django.db import models
9 10
 from django.db.models.query import Q, ITER_CHUNK_SIZE
@@ -483,23 +484,6 @@ class Related(models.Model):
483 484
 >>> Cover.objects.all()
484 485
 [<Cover: first>, <Cover: second>]
485 486
 
486  
-# If you're not careful, it's possible to introduce infinite loops via default
487  
-# ordering on foreign keys in a cycle. We detect that.
488  
->>> LoopX.objects.all()
489  
-Traceback (most recent call last):
490  
-...
491  
-FieldError: Infinite loop caused by ordering.
492  
-
493  
->>> LoopZ.objects.all()
494  
-Traceback (most recent call last):
495  
-...
496  
-FieldError: Infinite loop caused by ordering.
497  
-
498  
-# ... but you can still order in a non-recursive fashion amongst linked fields
499  
-# (the previous test failed because the default ordering was recursive).
500  
->>> LoopX.objects.all().order_by('y__x__y__x__id')
501  
-[]
502  
-
503 487
 # If the remote model does not have a default ordering, we order by its 'id'
504 488
 # field.
505 489
 >>> Item.objects.order_by('creator', 'name')
@@ -840,3 +824,27 @@ class Related(models.Model):
840 824
 
841 825
 """}
842 826
 
  827
+# In Python 2.3, exceptions raised in __len__ are swallowed (Python issue
  828
+# 1242657), so these cases return an empty list, rather than raising an
  829
+# exception. Not a lot we can do about that, unfortunately, due to the way
  830
+# Python handles list() calls internally. Thus, we skip the tests for Python
  831
+# 2.3.
  832
+if sys.version_info >= (2, 4):
  833
+    __test__["API_TESTS"] += """
  834
+# If you're not careful, it's possible to introduce infinite loops via default
  835
+# ordering on foreign keys in a cycle. We detect that.
  836
+>>> LoopX.objects.all()
  837
+Traceback (most recent call last):
  838
+...
  839
+FieldError: Infinite loop caused by ordering.
  840
+
  841
+>>> LoopZ.objects.all()
  842
+Traceback (most recent call last):
  843
+...
  844
+FieldError: Infinite loop caused by ordering.
  845
+
  846
+# ... but you can still order in a non-recursive fashion amongst linked fields
  847
+# (the previous test failed because the default ordering was recursive).
  848
+>>> LoopX.objects.all().order_by('y__x__y__x__id')
  849
+[]
  850
+"""

0 notes on commit 431206a

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