#15142: Contrib tests throwing errors on bare project when cache middleware 
enabled
and cache specified
-----------------------------------+----------------------------------------
          Reporter:  jsdalton      |         Owner:  nobody
            Status:  new           |     Milestone:  1.3   
         Component:  Contrib apps  |       Version:  SVN   
        Resolution:                |      Keywords:        
             Stage:  Unreviewed    |     Has_patch:  1     
        Needs_docs:  0             |   Needs_tests:  0     
Needs_better_patch:  0             |  
-----------------------------------+----------------------------------------
Changes (by jsdalton):

  * needs_better_patch:  => 0
  * has_patch:  0 => 1
  * needs_docs:  => 0
  * needs_tests:  => 0
  * milestone:  => 1.3

Comment:

 I have traced the cause of these errors to some of the views that are
 created by contrib.auth and contrib.messages, in the urls.py file of each.
 These views are created for the purposes of running tests against them.

 The problem is that some of the these views are hit multiple times in a
 test run. When a view is hit a second time, the cache is returned to the
 test client (it would appear). In any case, the `context` attribute, which
 is normally set by the test client in the 'response` is not set (i.e. it
 is `None`) when a cache page is retrieved.. As a result, the tests cause
 an error like the one in the description of the ticket.

 My proposed solution to the problem is to affix the `@never_cache`
 decorator to the views created by the contrib apps for testing. These
 views are only used in testing, and no aspect of the caching system is
 tested during those test runs. In fact, the desired behavior of the views,
 per the test code, *is* to get a fresh response, with context.

 A patch with this solution is attached. Applying this patch and then re-
 running the tests with the setup described in the ticket description will
 result in a clean test run (no errors or failures).

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15142#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to