diff options
| author | Aymeric Augustin | 2013-11-10 10:10:28 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-11-10 16:02:49 +0100 | 
| commit | f92aba225936fa768c098a8f1db51125ac1715ec (patch) | |
| tree | f853c2a91723157ad56b1765d03dcfbffd3e0b22 /tests/panels/test_template.py | |
| parent | 6a8526a93b60ebae214dbe0d4cbf172c311802b9 (diff) | |
| download | django-debug-toolbar-f92aba225936fa768c098a8f1db51125ac1715ec.tar.bz2 | |
Disable instrumentation for disabled panels.
This eliminates the performance overhead when a panel is disabled.
Diffstat (limited to 'tests/panels/test_template.py')
| -rw-r--r-- | tests/panels/test_template.py | 9 | 
1 files changed, 7 insertions, 2 deletions
| diff --git a/tests/panels/test_template.py b/tests/panels/test_template.py index c98521e..545ad9b 100644 --- a/tests/panels/test_template.py +++ b/tests/panels/test_template.py @@ -18,6 +18,12 @@ class TemplateDebugPanelTestCase(BaseTestCase):      def setUp(self):          super(TemplateDebugPanelTestCase, self).setUp()          self.panel = self.toolbar.get_panel(TemplateDebugPanel) +        self.sql_panel = self.toolbar.get_panel(SQLDebugPanel) +        self.sql_panel.enable_instrumentation() + +    def tearDown(self): +        self.sql_panel.disable_instrumentation() +        super(TemplateDebugPanelTestCase, self).tearDown()      def test_queryset_hook(self):          t = Template("No context variables here!") @@ -30,8 +36,7 @@ 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) +        self.assertEqual(len(self.sql_panel._queries), 0)          base_ctx_idx = 1 if django.VERSION[:2] >= (1, 5) else 0          ctx = self.panel.templates[0]['context'][base_ctx_idx] | 
