From ccbf178a3351106e25422b898f09cdca60a1c6e5 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 18 Oct 2013 18:08:17 +0200 Subject: Fix crash with objects having a non-ASCII repr in context. --- tests/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests/views.py') 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 = '