aboutsummaryrefslogtreecommitdiffstats
path: root/tests/panels/test_template.py
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-09 20:03:47 +0100
committerAymeric Augustin2013-11-10 10:39:42 +0100
commitc4e833ad77f21419b8d8239279b4bb162d01fd8f (patch)
tree5b17d28bfef86aaaf968ce6b36ab0d84c3f714bb /tests/panels/test_template.py
parenta29bbc7cfcef52af29960f2a2f3d53e9c0b0015d (diff)
downloaddjango-debug-toolbar-c4e833ad77f21419b8d8239279b4bb162d01fd8f.tar.bz2
Move a test specific to the template panel in its module.
Diffstat (limited to 'tests/panels/test_template.py')
-rw-r--r--tests/panels/test_template.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/panels/test_template.py b/tests/panels/test_template.py
index 4e30a73..c98521e 100644
--- a/tests/panels/test_template.py
+++ b/tests/panels/test_template.py
@@ -1,3 +1,5 @@
+# coding: utf-8
+
from __future__ import unicode_literals
import django
@@ -8,13 +10,16 @@ from debug_toolbar.panels.template import TemplateDebugPanel
from debug_toolbar.panels.sql import SQLDebugPanel
from ..base import BaseTestCase
+from ..models import NonAsciiRepr
class TemplateDebugPanelTestCase(BaseTestCase):
+ def setUp(self):
+ super(TemplateDebugPanelTestCase, self).setUp()
+ self.panel = self.toolbar.get_panel(TemplateDebugPanel)
+
def test_queryset_hook(self):
- template_panel = self.toolbar.get_panel(TemplateDebugPanel)
- sql_panel = self.toolbar.get_panel(SQLDebugPanel)
t = Template("No context variables here!")
c = Context({
'queryset': User.objects.all(),
@@ -23,9 +28,20 @@ class TemplateDebugPanelTestCase(BaseTestCase):
}
})
t.render(c)
+
# ensure the query was NOT logged
+ sql_panel = self.toolbar.get_panel(SQLDebugPanel)
self.assertEqual(len(sql_panel._queries), 0)
+
base_ctx_idx = 1 if django.VERSION[:2] >= (1, 5) else 0
- ctx = template_panel.templates[0]['context'][base_ctx_idx]
+ ctx = self.panel.templates[0]['context'][base_ctx_idx]
self.assertIn('<<queryset of auth.User>>', ctx)
self.assertIn('<<triggers database query>>', ctx)
+
+ def test_object_with_non_ascii_repr_in_context(self):
+ self.panel.process_request(self.request)
+ t = Template("{{ object }}")
+ c = Context({'object': NonAsciiRepr()})
+ t.render(c)
+ self.panel.process_response(self.request, self.response)
+ self.assertIn('nôt åscíì', self.panel.content())