Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
Cache settings override does not work

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
about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda