#11505: Django's TestCase should reset the cache
-------------------------------------+------------------------------------
     Reporter:  andrewfong           |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Testing framework    |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  cache testing flush  |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+------------------------------------
Comment (by Kayvan Sylvan):

 You can do this automatically for all tests by adding a pytest fixture
 like this. The operative part is ''autouse=True''


 {{{
 from django.conf import settings
 from django.core.cache import cache

 @pytest.fixture(autouse=True)
 def reset_cache():
     yield
     assert (
         settings.CACHES['default']['BACKEND']
         == 'django.core.cache.backends.locmem.LocMemCache'
     )
     cache.clear()

 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/11505#comment:25>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070192cef93b60-4b33dc27-5686-46dc-a0a2-cce62eb2d1aa-000000%40eu-central-1.amazonses.com.

Reply via email to