Opened 13 years ago
Closed 13 years ago
#17020 closed Bug (duplicate)
Error in Tests: Causes a TemplateNotFound Exception
Reported by: | Donald Stufft | Owned by: | nobody |
---|---|---|---|
Component: | contrib.messages | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In a number of the django contrib app tests they assume that there will not be 500.html template and they set TEMPLATE_DIRS to () to make sure that the project isn't including one. However if an INSTALLED_APPS app included a 500.html template then some of the tests throw exceptions.
I think that the Django Tests that knowingly raise an exception in a view should make sure that either a) only itself and it's dependencies are in INSTALLED_APPS b) override any 500.html template with their own or c) Remove the app loader from TEMPLATE_LOADERS
For what it's worth here is the test output:
====================================================================== ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.cookie.CookieTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/contrib/messages/tests/base.py", line 294, in test_middleware_disabled_anon_user data, follow=True) File "/usr/local/Cellar/python/2.7.2/lib/python2.7/unittest/case.py", line 471, in assertRaises callableObj(*args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 449, in post response = super(Client, self).post(path, data=data, content_type=content_type, **extra) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 259, in post return self.request(**r) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 381, in request response = self.handler(environ) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 84, in __call__ response = self.get_response(request) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception return callback(request, **param_dict) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/views/defaults.py", line 31, in server_error return http.HttpResponseServerError(t.render(Context({}))) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 123, in render return self._render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/utils.py", line 60, in instrumented_test_render return self.nodelist.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 744, in render bits.append(self.render_node(node, context)) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/debug.py", line 73, in render_node result = node.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 105, in render compiled_parent = self.get_parent(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 102, in get_parent return get_template(parent) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template template, origin = find_template(template_name) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template raise TemplateDoesNotExist(name) TemplateSyntaxError: Caught TemplateDoesNotExist while rendering: site_base.html ====================================================================== ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.fallback.FallbackTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/contrib/messages/tests/base.py", line 294, in test_middleware_disabled_anon_user data, follow=True) File "/usr/local/Cellar/python/2.7.2/lib/python2.7/unittest/case.py", line 471, in assertRaises callableObj(*args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 449, in post response = super(Client, self).post(path, data=data, content_type=content_type, **extra) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 259, in post return self.request(**r) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 381, in request response = self.handler(environ) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 84, in __call__ response = self.get_response(request) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception return callback(request, **param_dict) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/views/defaults.py", line 31, in server_error return http.HttpResponseServerError(t.render(Context({}))) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 123, in render return self._render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/utils.py", line 60, in instrumented_test_render return self.nodelist.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 744, in render bits.append(self.render_node(node, context)) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/debug.py", line 73, in render_node result = node.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 105, in render compiled_parent = self.get_parent(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 102, in get_parent return get_template(parent) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template template, origin = find_template(template_name) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template raise TemplateDoesNotExist(name) TemplateSyntaxError: Caught TemplateDoesNotExist while rendering: site_base.html ====================================================================== ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.user_messages.LegacyFallbackTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/contrib/messages/tests/base.py", line 294, in test_middleware_disabled_anon_user data, follow=True) File "/usr/local/Cellar/python/2.7.2/lib/python2.7/unittest/case.py", line 471, in assertRaises callableObj(*args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 449, in post response = super(Client, self).post(path, data=data, content_type=content_type, **extra) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 259, in post return self.request(**r) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 381, in request response = self.handler(environ) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 84, in __call__ response = self.get_response(request) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception return callback(request, **param_dict) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/views/defaults.py", line 31, in server_error return http.HttpResponseServerError(t.render(Context({}))) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 123, in render return self._render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/utils.py", line 60, in instrumented_test_render return self.nodelist.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 744, in render bits.append(self.render_node(node, context)) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/debug.py", line 73, in render_node result = node.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 105, in render compiled_parent = self.get_parent(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 102, in get_parent return get_template(parent) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template template, origin = find_template(template_name) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template raise TemplateDoesNotExist(name) TemplateSyntaxError: Caught TemplateDoesNotExist while rendering: site_base.html ====================================================================== ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.session.SessionTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/contrib/messages/tests/base.py", line 294, in test_middleware_disabled_anon_user data, follow=True) File "/usr/local/Cellar/python/2.7.2/lib/python2.7/unittest/case.py", line 471, in assertRaises callableObj(*args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 449, in post response = super(Client, self).post(path, data=data, content_type=content_type, **extra) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 259, in post return self.request(**r) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 381, in request response = self.handler(environ) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/client.py", line 84, in __call__ response = self.get_response(request) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception return callback(request, **param_dict) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/views/defaults.py", line 31, in server_error return http.HttpResponseServerError(t.render(Context({}))) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 123, in render return self._render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/test/utils.py", line 60, in instrumented_test_render return self.nodelist.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/base.py", line 744, in render bits.append(self.render_node(node, context)) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/debug.py", line 73, in render_node result = node.render(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 105, in render compiled_parent = self.get_parent(context) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader_tags.py", line 102, in get_parent return get_template(parent) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template template, origin = find_template(template_name) File "/Users/dstufft/.virtualenvs/testhub/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template raise TemplateDoesNotExist(name) TemplateSyntaxError: Caught TemplateDoesNotExist while rendering: site_base.html
Change History (2)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#16507 seems to tackle the same issue.