diff options
| author | David Cramer | 2011-06-14 12:54:46 -0700 |
|---|---|---|
| committer | David Cramer | 2011-06-14 12:54:46 -0700 |
| commit | b431d64f3b9722f7ae17f30f0168412d419c0d43 (patch) | |
| tree | 71e6f303fc777a24020024bf5b223e6f78dbc4c6 /tests/tests.py | |
| parent | 7504141f19ef1bdaaf91d95461dad35ac84b5211 (diff) | |
| download | django-debug-toolbar-b431d64f3b9722f7ae17f30f0168412d419c0d43.tar.bz2 | |
Moved view function name extraction into debug_toolbar.utils.get_name_from_obj
Diffstat (limited to 'tests/tests.py')
| -rw-r--r-- | tests/tests.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/tests.py b/tests/tests.py index 84b4418..4936775 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,10 +2,12 @@ from debug_toolbar.middleware import DebugToolbarMiddleware from debug_toolbar.panels.sql import SQLDebugPanel from debug_toolbar.panels.request_vars import RequestVarsDebugPanel from debug_toolbar.toolbar.loader import DebugToolbar +from debug_toolbar.utils import get_name_from_obj from debug_toolbar.utils.tracking import pre_dispatch, post_dispatch, callbacks from django.conf import settings from django.contrib.auth.models import User +from django.http import HttpResponse from django.test import TestCase from dingus import Dingus @@ -145,7 +147,7 @@ class DebugToolbarTestCase(BaseTestCase): panel.process_request(request) panel.process_view(request, _test_view, [], {}) content = panel.content() - self.assertIn('debug_toolbar.tests.tests._test_view', content) + self.assertIn('tests.tests._test_view', content) def test_without_process_view(self): request = self.request @@ -156,6 +158,22 @@ class DebugToolbarTestCase(BaseTestCase): content = panel.content() self.assertIn('<no view>', content) +class DebugToolbarNameFromObjectTest(BaseTestCase): + def test_func(self): + def x(): + return 1 + res = get_name_from_obj(x) + self.assertEquals(res, 'tests.tests.x') + + def test_lambda(self): + res = get_name_from_obj(lambda:1) + self.assertEquals(res, 'tests.tests.<lambda>') + + def test_class(self): + class A: pass + res = get_name_from_obj(A) + self.assertEquals(res, 'tests.tests.A') + class SQLPanelTestCase(BaseTestCase): def test_recording(self): panel = self.toolbar.get_panel(SQLDebugPanel) |
