This is my cache setting:
ENABLE_CACHING = True
if ENABLE_CACHING:
CACHES = get_cache()
else:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
I tried to override this setting in two ways:
@override_settings(ENABLE_CACHING=False)
@override_settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}})
class IndexViewTests(TestCase):
def test_index_view_with_a_future_question(self):
"""
Questions with a pub_date in the future should not be displayed on
the index page.
"""
create_question('Future question', 1,
[Choice(choice_text='Dummy choice')])
response = self.client.get(reverse('polls:index'))
self.assertEqual(response.status_code, 200)
self.assertQuerysetEqual(response.context['latest_questions'], [])
self.assertEqual(response.context['total_questions'], 1)
self.assertEqual(response.context['total_votes'], 0)
Both do not override the settings and I have to do it manually again. How can this be fixed? This is a example failed test result caused by enabled caching:
ERROR: test_index_view_with_a_future_question (polls.tests.IndexViewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/david/Projects/easypolls/polls/tests.py", line 375, in test_index_view_with_a_future_question
self.assertQuerysetEqual(response.context['latest_questions'], [])
TypeError: 'NoneType' object is not subscriptable