From 96f1cb4b0d4b10903502e917ddaa460bc05f5ca3 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 1 Nov 2013 21:51:37 +0100 Subject: Split tests across several modules. Fix #426. --- tests/panels/test_template.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/panels/test_template.py (limited to 'tests/panels/test_template.py') diff --git a/tests/panels/test_template.py b/tests/panels/test_template.py new file mode 100644 index 0000000..4e30a73 --- /dev/null +++ b/tests/panels/test_template.py @@ -0,0 +1,31 @@ +from __future__ import unicode_literals + +import django +from django.contrib.auth.models import User +from django.template import Template, Context + +from debug_toolbar.panels.template import TemplateDebugPanel +from debug_toolbar.panels.sql import SQLDebugPanel + +from ..base import BaseTestCase + + +class TemplateDebugPanelTestCase(BaseTestCase): + + 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(), + 'deep_queryset': { + 'queryset': User.objects.all(), + } + }) + t.render(c) + # ensure the query was NOT logged + 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] + self.assertIn('<>', ctx) + self.assertIn('<>', ctx) -- cgit v1.2.3