diff options
| -rw-r--r-- | tests/models.py | 10 | ||||
| -rw-r--r-- | tests/tests.py | 4 | ||||
| -rw-r--r-- | tests/urls.py | 4 | ||||
| -rw-r--r-- | tests/views.py | 5 |
4 files changed, 20 insertions, 3 deletions
diff --git a/tests/models.py b/tests/models.py index e69de29..24358c0 100644 --- a/tests/models.py +++ b/tests/models.py @@ -0,0 +1,10 @@ +# coding: utf-8 + +from __future__ import unicode_literals + +from django.utils import six + + +class NonAsciiRepr(object): + def __repr__(self): + return 'nôt åscíì' if six.PY3 else 'nôt åscíì'.encode('utf-8') diff --git a/tests/tests.py b/tests/tests.py index 86622fc..7e1757f 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -196,6 +196,10 @@ class DebugToolbarIntegrationTestCase(TestCase): response = self.client.get('/non_ascii_context/') self.assertContains(response, 'nôt åscíì') + def test_object_with_non_ascii_repr_in_request_vars(self): + response = self.client.get('/non_ascii_request/') + self.assertContains(response, 'nôt åscíì') + def test_xml_validation(self): response = self.client.get('/regular/XML/') ET.fromstring(response.content) # shouldn't raise ParseError diff --git a/tests/urls.py b/tests/urls.py index d9ecb8c..562ebd2 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -10,6 +10,9 @@ from __future__ import unicode_literals from django.conf.urls import patterns, url from django.contrib import admin +from .models import NonAsciiRepr + + admin.autodiscover() urlpatterns = patterns('tests.views', @@ -19,5 +22,6 @@ urlpatterns = patterns('tests.views', url(r'^resolving3/(.+)/$', 'resolving_view', { 'arg2' : 'default' }), url(r'^regular/(?P<title>.*)/$', 'regular_view'), url(r'^non_ascii_context/$', 'non_ascii_context'), + url(r'^non_ascii_request/$', 'regular_view', {'title': NonAsciiRepr()}), url(r'^execute_sql/$', 'execute_sql'), ) diff --git a/tests/views.py b/tests/views.py index 5bafc97..2fba2a7 100644 --- a/tests/views.py +++ b/tests/views.py @@ -7,6 +7,8 @@ from django.http import HttpResponse from django.shortcuts import render from django.utils import six +from .models import NonAsciiRepr + def execute_sql(request): list(User.objects.all()) @@ -14,9 +16,6 @@ def execute_sql(request): 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()}) |
