#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: Accepted | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -----------------------------------+---------------------------------------- Comment (by jsdalton):
Thanks Russ. To clarify, for at least a few of the test errors related to this issue, the page is viewed multiple times in the same test *method*, e.g. RemoteUserTest.test_no_remote_user() in contrib.auth.tests. (I said test "run" above, which was inaccurate.) So it doesn't really matter whether we get the teardown right or not...the test needs to ensure the view is not cached in order to be run correctly. The same is true in a few of the other test methods (though I have not gone through and systematically analyzed whether the methods that are throwing errors are all calling the same view multiple times in a test method). So I think in this case ensuring the view is not cached is really the only satisfactory way. The only alternative would be to determine the cache key used to save the response and go in and delete it, which seems burdensome. I do agree with your overall point. We had a similar discussion on a similar issue #15026. The fact is, the Django test suite does an excellent job of restoring most of the major systems (e.g. DB, mail outbox) to their pre-test state state for each test method run, but cache (memcached at least) does not. I agree that calling flush() is problematic, because there are many examples where that would be undesirable behavior. I don't have any great ideas as to how one could clean up the cache after each test but only flush those keys that were set during that test, but maybe there's an idea lurking somewhere there... -- Ticket URL: <http://code.djangoproject.com/ticket/15142#comment:4> 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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.