aboutsummaryrefslogtreecommitdiffstats
path: root/tests/views.py
diff options
context:
space:
mode:
authorAymeric Augustin2013-10-18 18:08:17 +0200
committerAymeric Augustin2013-10-18 18:09:15 +0200
commitccbf178a3351106e25422b898f09cdca60a1c6e5 (patch)
tree442eb02929f8b2ed640a7d864242c4ee81f4b3cd /tests/views.py
parent7196171fadb3478b660451bed344bf13c270f9af (diff)
downloaddjango-debug-toolbar-ccbf178a3351106e25422b898f09cdca60a1c6e5.tar.bz2
Fix crash with objects having a non-ASCII repr in context.
Diffstat (limited to 'tests/views.py')
-rw-r--r--tests/views.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/views.py b/tests/views.py
index 8b51706..5bafc97 100644
--- a/tests/views.py
+++ b/tests/views.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.http import HttpResponse
+from django.shortcuts import render
from django.utils import six
@@ -12,9 +13,15 @@ def execute_sql(request):
return HttpResponse()
+def non_ascii_context(request):
+ class NonAsciiRepr(object):
+ def __repr__(self):
+ return 'nôt åscíì' if six.PY3 else 'nôt åscíì'.encode('utf-8')
+ return render(request, 'basic.html', {'title': NonAsciiRepr()})
+
+
def regular_view(request, title):
- content = '<html><head><title>%s</title></head><body></body></html>' % title
- return HttpResponse(content)
+ return render(request, 'basic.html', {'title': title})
def resolving_view(request, arg1, arg2):
@@ -26,4 +33,4 @@ def set_session(request):
request.session['où'] = 'où'
if not six.PY3:
request.session['là'.encode('utf-8')] = 'là'.encode('utf-8')
- return HttpResponse('<html><head></head><body></body></html>')
+ return render(request, 'basic.html')