Move the tests added for #12302 to where some other tests for debug page responses already existed.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bae921dcff
commit
5a35619b5b
|
@ -1,10 +0,0 @@
|
||||||
# -*- coding: utf8 -*-
|
|
||||||
|
|
||||||
class BrokenException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
except_args = ('Broken!', # plain exception with ASCII text
|
|
||||||
u'¡Broken!', # non-ASCII unicode data
|
|
||||||
'¡Broken!', # non-ASCII, utf-8 encoded bytestring
|
|
||||||
'\xa1Broken!', ) # non-ASCII, latin1 bytestring
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
from django.conf import settings
|
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
|
|
||||||
from regressiontests.debug import BrokenException, except_args
|
|
||||||
|
|
||||||
class ExceptionTest(TestCase):
|
|
||||||
urls = 'regressiontests.debug.urls'
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.old_debug = settings.DEBUG
|
|
||||||
settings.DEBUG = True
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
settings.DEBUG = self.old_debug
|
|
||||||
|
|
||||||
def test_view_exceptions(self):
|
|
||||||
for n in range(len(except_args)):
|
|
||||||
self.assertRaises(BrokenException, self.client.get,
|
|
||||||
reverse('view_exception', args=(n,)))
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
from django.conf.urls.defaults import *
|
|
||||||
|
|
||||||
urlpatterns = patterns('regressiontests.debug.views',
|
|
||||||
url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
|
|
||||||
)
|
|
|
@ -1,5 +0,0 @@
|
||||||
from regressiontests.debug import BrokenException, except_args
|
|
||||||
|
|
||||||
def view_exception(request, n):
|
|
||||||
raise BrokenException(except_args[int(n)])
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# -*- coding: utf8 -*-
|
||||||
|
|
||||||
|
class BrokenException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
except_args = ('Broken!', # plain exception with ASCII text
|
||||||
|
u'¡Broken!', # non-ASCII unicode data
|
||||||
|
'¡Broken!', # non-ASCII, utf-8 encoded bytestring
|
||||||
|
'\xa1Broken!', ) # non-ASCII, latin1 bytestring
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
|
||||||
|
from regressiontests.views import BrokenException, except_args
|
||||||
|
|
||||||
class DebugViewTests(TestCase):
|
class DebugViewTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.old_debug = settings.DEBUG
|
||||||
settings.DEBUG = True
|
settings.DEBUG = True
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
settings.DEBUG = False
|
settings.DEBUG = self.old_debug
|
||||||
|
|
||||||
def test_files(self):
|
def test_files(self):
|
||||||
response = self.client.get('/views/raises/')
|
response = self.client.get('/views/raises/')
|
||||||
|
@ -23,3 +27,9 @@ class DebugViewTests(TestCase):
|
||||||
def test_404(self):
|
def test_404(self):
|
||||||
response = self.client.get('/views/raises404/')
|
response = self.client.get('/views/raises404/')
|
||||||
self.assertEquals(response.status_code, 404)
|
self.assertEquals(response.status_code, 404)
|
||||||
|
|
||||||
|
def test_view_exceptions(self):
|
||||||
|
for n in range(len(except_args)):
|
||||||
|
self.assertRaises(BrokenException, self.client.get,
|
||||||
|
reverse('view_exception', args=(n,)))
|
||||||
|
|
||||||
|
|
|
@ -107,3 +107,6 @@ urlpatterns += patterns('django.views.generic.simple',
|
||||||
{'url': u'/views/中文/target/', 'permanent': True}),
|
{'url': u'/views/中文/target/', 'permanent': True}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
urlpatterns += patterns('regressiontests.views.views',
|
||||||
|
url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
|
||||||
|
)
|
||||||
|
|
|
@ -6,6 +6,8 @@ from django.views.debug import technical_500_response
|
||||||
from django.views.generic.create_update import create_object
|
from django.views.generic.create_update import create_object
|
||||||
from django.core.urlresolvers import get_resolver
|
from django.core.urlresolvers import get_resolver
|
||||||
|
|
||||||
|
from regressiontests.views import BrokenException, except_args
|
||||||
|
|
||||||
from models import Article
|
from models import Article
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,10 +42,13 @@ def raises(request):
|
||||||
def raises404(request):
|
def raises404(request):
|
||||||
resolver = get_resolver(None)
|
resolver = get_resolver(None)
|
||||||
resolver.resolve('')
|
resolver.resolve('')
|
||||||
|
|
||||||
def redirect(request):
|
def redirect(request):
|
||||||
"""
|
"""
|
||||||
Forces an HTTP redirect.
|
Forces an HTTP redirect.
|
||||||
"""
|
"""
|
||||||
return HttpResponseRedirect("target/")
|
return HttpResponseRedirect("target/")
|
||||||
|
|
||||||
|
def view_exception(request, n):
|
||||||
|
raise BrokenException(except_args[int(n)])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue