Skip to content
This repository
Browse code

Got rid of the dependency on Dingus.

  • Loading branch information...
commit 971334eb38561d4721788e7d1b0fb9d7cab3bbf7 1 parent 7f7ea81
Jannis Leidel jezdez authored

Showing 2 changed files with 22 additions and 31 deletions. Show diff stats Hide diff stats

  1. +1 2  setup.py
  2. +21 29 tests/tests.py
3  setup.py
@@ -13,8 +13,7 @@
13 13 license='BSD',
14 14 packages=find_packages(exclude=('tests', 'example')),
15 15 tests_require=[
16   - 'django>=1.1,<1.5',
17   - 'dingus',
  16 + 'django>=1.3,<1.5',
18 17 ],
19 18 test_suite='runtests.runtests',
20 19 include_package_data=True,
50 tests/tests.py
... ... @@ -1,3 +1,12 @@
  1 +import thread
  2 +
  3 +from django.conf import settings
  4 +from django.contrib.auth.models import User
  5 +from django.http import HttpResponse
  6 +from django.test import TestCase, RequestFactory
  7 +from django.template import Template, Context
  8 +from django import VERSION
  9 +
1 10 from debug_toolbar.middleware import DebugToolbarMiddleware
2 11 from debug_toolbar.panels.sql import SQLDebugPanel
3 12 from debug_toolbar.panels.request_vars import RequestVarsDebugPanel
@@ -6,15 +15,7 @@
6 15 from debug_toolbar.utils import get_name_from_obj
7 16 from debug_toolbar.utils.tracking import pre_dispatch, post_dispatch, callbacks
8 17
9   -from django.conf import settings
10   -from django.contrib.auth.models import User
11   -from django.http import HttpResponse
12   -from django.test import TestCase
13   -from django.template import Template, Context
14   -from django import VERSION
15   -
16   -from dingus import Dingus
17   -import thread
  18 +rf = RequestFactory()
18 19
19 20
20 21 class Settings(object):
@@ -38,10 +39,11 @@ def __exit__(self, exc_type, exc_value, traceback):
38 39 else:
39 40 setattr(settings, k, v)
40 41
  42 +
41 43 class BaseTestCase(TestCase):
42 44 def setUp(self):
43   - request = Dingus('request')
44   - response = Dingus('response')
  45 + request = rf.get('/')
  46 + response = HttpResponse()
45 47 toolbar = DebugToolbar(request)
46 48
47 49 DebugToolbarMiddleware.debug_toolbars[thread.get_ident()] = toolbar
@@ -51,6 +53,7 @@ def setUp(self):
51 53 self.toolbar = toolbar
52 54 self.toolbar.stats = {}
53 55
  56 +
54 57 class DebugToolbarTestCase(BaseTestCase):
55 58 urls = 'tests.urls'
56 59
@@ -60,9 +63,7 @@ def test_middleware(self):
60 63 self.assertEquals(resp.status_code, 200)
61 64
62 65 def test_show_toolbar_DEBUG(self):
63   - request = self.request
64   -
65   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
  66 + request = rf.get('/')
66 67 middleware = DebugToolbarMiddleware()
67 68
68 69 with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
@@ -72,9 +73,7 @@ def test_show_toolbar_DEBUG(self):
72 73 self.assertFalse(middleware._show_toolbar(request))
73 74
74 75 def test_show_toolbar_TEST(self):
75   - request = self.request
76   -
77   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
  76 + request = rf.get('/')
78 77 middleware = DebugToolbarMiddleware()
79 78
80 79 with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=True, DEBUG=True):
@@ -84,7 +83,7 @@ def test_show_toolbar_TEST(self):
84 83 self.assertTrue(middleware._show_toolbar(request))
85 84
86 85 def test_show_toolbar_INTERNAL_IPS(self):
87   - request = self.request
  86 + request = rf.get('/')
88 87
89 88 request.META = {'REMOTE_ADDR': '127.0.0.1'}
90 89 middleware = DebugToolbarMiddleware()
@@ -96,10 +95,8 @@ def test_show_toolbar_INTERNAL_IPS(self):
96 95 self.assertFalse(middleware._show_toolbar(request))
97 96
98 97 def test_request_urlconf_string(self):
99   - request = self.request
100   -
  98 + request = rf.get('/')
101 99 request.urlconf = 'tests.urls'
102   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
103 100 middleware = DebugToolbarMiddleware()
104 101
105 102 with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
@@ -113,10 +110,8 @@ def test_request_urlconf_string(self):
113 110 self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
114 111
115 112 def test_request_urlconf_string_per_request(self):
116   - request = self.request
117   -
  113 + request = rf.get('/')
118 114 request.urlconf = 'debug_toolbar.urls'
119   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
120 115 middleware = DebugToolbarMiddleware()
121 116
122 117 with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
@@ -132,10 +127,8 @@ def test_request_urlconf_string_per_request(self):
132 127 self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
133 128
134 129 def test_request_urlconf_module(self):
135   - request = self.request
136   -
  130 + request = rf.get('/')
137 131 request.urlconf = __import__('tests.urls').urls
138   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
139 132 middleware = DebugToolbarMiddleware()
140 133
141 134 with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
@@ -149,11 +142,10 @@ def test_request_urlconf_module(self):
149 142 self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
150 143
151 144 def test_tuple_urlconf(self):
152   - request = self.request
  145 + request = rf.get('/')
153 146 urls = __import__('tests.urls').urls
154 147 urls.urlpatterns = tuple(urls.urlpatterns)
155 148 request.urlconf = urls
156   - request.META = {'REMOTE_ADDR': '127.0.0.1'}
157 149 middleware = DebugToolbarMiddleware()
158 150 with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
159 151 middleware.process_request(request)

0 comments on commit 971334e

Gunnlaugur Thor Briem

Readme says Django>=1.2 — which is it? :)

Please sign in to comment.
Something went wrong with that request. Please try again.