Skip to content

Commit 3b0da34

Browse files
committed
Added unit tests for Fixed django-commons#792
1 parent c6986fe commit 3b0da34

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/panels/test_profiling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ def test_listcomp_escaped(self):
4747
self.assertNotIn('<span class="djdt-func"><listcomp></span>', self.panel.content)
4848
self.assertIn('<span class="djdt-func">&lt;listcomp&gt;</span>', self.panel.content)
4949

50+
def test_generate_stats_no_profiler(self):
51+
"""
52+
Test generating stats with no profiler.
53+
"""
54+
self.assertIsNone(self.panel.generate_stats(self.request, self.response))
55+
56+
def test_generate_stats_no_root_func(self):
57+
"""
58+
Test generating stats using profiler without root function.
59+
"""
60+
self.panel.process_view(self.request, regular_view, ('profiling',), {})
61+
self.panel.process_response(self.request, self.response)
62+
self.panel.profiler.clear()
63+
self.panel.profiler.enable()
64+
self.panel.profiler.disable()
65+
self.panel.generate_stats(self.request, self.response)
66+
self.assertNotIn('func_list', self.panel.get_stats())
67+
5068

5169
@override_settings(DEBUG=True,
5270
DEBUG_TOOLBAR_PANELS=['debug_toolbar.panels.profiling.ProfilingPanel'])

0 commit comments

Comments
 (0)