#14105: django.contrib.auth tests failing with cache middleware -----------------------------------+---------------------------------------- Reporter: baumer1122 | Owner: PaulM Status: assigned | Milestone: Component: Contrib apps | Version: 1.2 Resolution: | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -----------------------------------+---------------------------------------- Comment (by toofishes):
This bug comes down to the following line in client.py:224: {{{ signals.template_rendered.connect(on_template_render, dispatch_uid ="template-render") }}} The problem occurs when a view is rendered any subsequent time in the test run- we will never render any templates, causing our signal that attempts to trap template and context items to never fire, which in turn leads to context and template attributes on HttpResponse being left empty/undefined even though the response content itself and the status_code end up being correct. I'm not sure of the solution here; they all seem ugly: * Always set CACHE_BACKEND to 'dummy://' when running tests- sucks if you actually want to test caching concerns like making sure different views go to different users even with caching enabled. * Set CACHE_BACKEND to 'dummy://' in supplied tests when we know we want to examine context or templates in the response. * Remove cache middleware explicitly from settings.MIDDLEWARE_CLASSES in these tests. * Call cache.clear() in test setup/teardown- seems like overkill and is potentially non-safe it people aren't careful about their setup. * Attempt to set template and context before the response ends up being cached, so when we later retrieve it we get the same results as the first non-cached run. -- Ticket URL: <http://code.djangoproject.com/ticket/14105#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-upda...@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.