Django

Code

Changeset 8030

Show
Ignore:
Timestamp:
07/21/08 12:28:21 (5 months ago)
Author:
lukeplant
Message:

Fixed #7825 - modeltests/delete tests failing after NFA merge, and improved documentation of these tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/delete/models.py

    r7722 r8030  
    4343 
    4444__test__ = {'API_TESTS': """ 
    45 # First, some tests for the datastructure we use 
     45### Tests for models A,B,C,D ### 
     46 
     47## First, test the CollectedObjects data structure directly 
    4648 
    4749>>> from django.db.models.query import CollectedObjects 
     
    7375 
    7476 
     77## Second, test the usage of CollectedObjects by Model.delete() 
    7578 
    7679# Due to the way that transactions work in the test harness, 
     
    8588# access to internals here :-) 
    8689 
     90# If implementation changes, then the tests may need to be simplified: 
     91#  - remove the lines that set the .keyOrder and clear the related 
     92#    object caches 
     93#  - remove the second set of tests (with a2, b2 etc) 
     94 
    8795>>> from django.db.models.loading import cache 
     96 
     97>>> def clear_rel_obj_caches(models): 
     98...     for m in models: 
     99...         if hasattr(m._meta, '_related_objects_cache'):  
     100...             del m._meta._related_objects_cache 
    88101 
    89102# Nice order 
    90103>>> cache.app_models['delete'].keyOrder = ['a', 'b', 'c', 'd'] 
    91 >>> del A._meta._related_objects_cache 
    92 >>> del B._meta._related_objects_cache 
    93 >>> del C._meta._related_objects_cache 
    94 >>> del D._meta._related_objects_cache 
     104>>> clear_rel_obj_caches([A, B, C, D]) 
    95105 
    96106>>> a1 = A() 
     
    111121# Same again with a known bad order 
    112122>>> cache.app_models['delete'].keyOrder = ['d', 'c', 'b', 'a'] 
    113 >>> del A._meta._related_objects_cache 
    114 >>> del B._meta._related_objects_cache 
    115 >>> del C._meta._related_objects_cache 
    116 >>> del D._meta._related_objects_cache 
     123>>> clear_rel_obj_caches([A, B, C, D]) 
    117124 
    118125>>> a2 = A() 
     
    131138>>> a2.delete() 
    132139 
    133 # Tests for nullable related fields 
     140### Tests for models E,F - nullable related fields ### 
     141 
     142## First, test the CollectedObjects data structure directly 
    134143 
    135144>>> g = CollectedObjects() 
     
    142151>>> g.ordered_keys() 
    143152['key1', 'key2'] 
     153 
     154## Second, test the usage of CollectedObjects by Model.delete() 
    144155 
    145156>>> e1 = E()