Django

Code

Changeset 7939

Show
Ignore:
Timestamp:
07/16/08 18:55:10 (4 months ago)
Author:
mtredinnick
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/regressiontests/queries/models.py

    r7938 r7939  
    55import datetime 
    66import pickle 
     7import sys 
    78 
    89from django.db import models 
     
    483484>>> Cover.objects.all() 
    484485[<Cover: first>, <Cover: second>] 
    485  
    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 [] 
    502486 
    503487# If the remote model does not have a default ordering, we order by its 'id' 
     
    841825"""} 
    842826 
     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. 
     832if 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() 
     837Traceback (most recent call last): 
     838... 
     839FieldError: Infinite loop caused by ordering. 
     840 
     841>>> LoopZ.objects.all() 
     842Traceback (most recent call last): 
     843... 
     844FieldError: 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"""