1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #7529: added a FILES section to the debug view. As a bonus, we've now got

the start of a suite of tests for the debug views. Thanks, Alex Gaynor.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10271 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-03-31 17:10:06 +00:00
parent 33e87318c0
commit cc5477df89
5 changed files with 58 additions and 0 deletions

View File

@ -611,6 +611,28 @@ Exception Value: {{ exception_value|escape }}
{% else %}
<p>No POST data</p>
{% endif %}
<h3 id="files-info">FILES</h3>
{% if request.FILES %}
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for var in request.FILES.items %}
<tr>
<td>{{ var.0 }}</td>
<td class="code"><div>{{ var.1|pprint }}</div></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No FILES data</p>
{% endif %}
<h3 id="cookie-info">COOKIES</h3>
{% if request.COOKIES %}

View File

@ -3,3 +3,4 @@ from i18n import *
from static import *
from generic.date_based import *
from generic.create_update import *
from debug import *

View File

@ -0,0 +1,21 @@
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
class DebugViewTests(TestCase):
def setUp(self):
settings.DEBUG = True
def tearDown(self):
settings.DEBUG = False
def test_files(self):
response = self.client.get('/views/raises/')
self.assertEquals(response.status_code, 500)
data = {
'file_data.txt': SimpleUploadedFile('file_data.txt', 'haha'),
}
response = self.client.post('/views/raises/', data)
self.failUnless('file_data.txt' in response.content)
self.failIf('haha' in response.content)

View File

@ -82,3 +82,8 @@ urlpatterns += patterns('django.views.generic.create_update',
(r'^create_update/no_url/update/article/(?P<slug>[-\w]+)/$',
'update_object', dict(slug_field='slug', model=UrlArticle)),
)
# a view that raises an exception for the debug view
urlpatterns += patterns('',
(r'^raises/$', views.raises)
)

View File

@ -1,5 +1,8 @@
import sys
from django.http import HttpResponse
from django import forms
from django.views.debug import technical_500_response
from django.views.generic.create_update import create_object
from models import Article
@ -27,3 +30,9 @@ def custom_create(request):
return create_object(request,
post_save_redirect='/views/create_update/view/article/%(slug)s/',
form_class=SlugChangingArticleForm)
def raises(request):
try:
raise Exception
except Exception:
return technical_500_response(request, *sys.exc_info())