Ticket #12083: patch_12083.diff
File patch_12083.diff, 2.4 KB (added by , 15 years ago) |
---|
-
django/views/debug.py
245 245 "Create a technical 404 error response. The exception should be the Http404." 246 246 try: 247 247 tried = exception.args[0]['tried'] 248 except (IndexError, TypeError ):248 except (IndexError, TypeError, KeyError): 249 249 tried = [] 250 250 else: 251 251 if not tried: -
tests/regressiontests/views/tests/debug.py
19 19 response = self.client.post('/views/raises/', data) 20 20 self.failUnless('file_data.txt' in response.content) 21 21 self.failIf('haha' in response.content) 22 23 def test_404(self): 24 response = self.client.get('/views/raises404/') 25 self.assertEquals(response.status_code, 404) 26 No newline at end of file -
tests/regressiontests/views/views.py
2 2 3 3 from django.http import HttpResponse, HttpResponseRedirect 4 4 from django import forms 5 from django.views.debug import technical_500_response 5 from django.views.debug import technical_500_response, technical_404_response 6 6 from django.views.generic.create_update import create_object 7 from django.core.urlresolvers import get_resolver 7 8 8 9 from models import Article 9 10 … … 37 38 except Exception: 38 39 return technical_500_response(request, *sys.exc_info()) 39 40 41 def raises404(request): 42 resolver = get_resolver(None) 43 try: 44 resolver.resolve('') 45 except Exception, e: 46 return technical_404_response(request, e) 47 40 48 def redirect(request): 41 49 """ 42 50 Forces an HTTP redirect. -
tests/regressiontests/views/urls.py
95 95 96 96 # a view that raises an exception for the debug view 97 97 urlpatterns += patterns('', 98 (r'^raises/$', views.raises) 98 (r'^raises/$', views.raises), 99 (r'^raises404/$', views.raises404) 99 100 )