Cache should be reset after each test without flushing
|Reported by:||jsdalton||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||yes|
At present, when cache values are set during a test, those values carry over from test to test. This breaks proper test isolation and can making testing code that uses the cache cumbersome, since cache values have to be manually flushed.
Using cache.clear() would be on option to handle this, however this clears *all* the data in a cache, not just for your application. This could be considered impolite at best and dangerous at worst, so a proper solution would not resort to this measure.
Here are some guidelines/requirements for a solution:
- Any cache(s) used during a test run should ideally be restored to their original state when the test run is finished.
- Any cache values set during an individual test should be cleared when that test is finished.
Some discussion on the developers list here: https://groups.google.com/forum/#!topic/django-developers/zlaPsP13dUY