aboutsummaryrefslogtreecommitdiffstats
path: root/tests/panels
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-22 17:52:24 +0100
committerAymeric Augustin2013-11-22 17:52:24 +0100
commite4d2e2b7b253be1690d54e3842f4c7a2a2ccc549 (patch)
treec9bc4fb40620b30112b3487bf50f7254d23f54e3 /tests/panels
parentefdd0ce313052dc390c0001b5dc8c56e888514d0 (diff)
downloaddjango-debug-toolbar-e4d2e2b7b253be1690d54e3842f4c7a2a2ccc549.tar.bz2
Add (failing) tests for the profiling panel.
Refs #466.
Diffstat (limited to 'tests/panels')
-rw-r--r--tests/panels/test_profiling.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/panels/test_profiling.py b/tests/panels/test_profiling.py
index fc76a39..4e01073 100644
--- a/tests/panels/test_profiling.py
+++ b/tests/panels/test_profiling.py
@@ -4,6 +4,44 @@ from django.contrib.auth.models import User
from django.db import IntegrityError, transaction
from django.test import TestCase
from django.test.utils import override_settings
+from django.utils import unittest
+
+try:
+ import line_profiler
+except ImportError:
+ line_profiler = None
+
+from debug_toolbar.panels import profiling
+
+from ..base import BaseTestCase
+from ..views import regular_view
+
+
+@override_settings(DEBUG_TOOLBAR_PANELS=['debug_toolbar.panels.profiling.ProfilingDebugPanel'])
+class ProfilingPanelTestCase(BaseTestCase):
+
+ def setUp(self):
+ super(ProfilingPanelTestCase, self).setUp()
+ self.panel = self.toolbar.get_panel_by_id('ProfilingDebugPanel')
+
+ def _test_render_with_or_without_line_profiler(self):
+ self.panel.process_view(self.request, regular_view, ('profiling',), {})
+ self.panel.process_response(self.request, self.response)
+ self.assertIn('func_list', self.panel.get_stats())
+ self.assertIn('regular_view', self.panel.content())
+
+ @unittest.skipIf(line_profiler is None, "line_profiler isn't available")
+ def test_render_with_line_profiler(self):
+ self._test_render_with_or_without_line_profiler()
+
+ def test_without_line_profiler(self):
+ _use_line_profiler = profiling.DJ_PROFILE_USE_LINE_PROFILER
+ profiling.DJ_PROFILE_USE_LINE_PROFILER = False
+ try:
+ self._test_render_with_or_without_line_profiler()
+ finally:
+ profiling.DJ_PROFILE_USE_LINE_PROFILER = _use_line_profiler
+
@override_settings(DEBUG=True,
@@ -11,7 +49,6 @@ from django.test.utils import override_settings
class ProfilingPanelIntegrationTestCase(TestCase):
def test_view_executed_once(self):
-
self.assertEqual(User.objects.count(), 0)
response = self.client.get('/new_user/')