Skip to content

Commit f99833a

Browse files
committed
Fixed a few cosmetic issues in the tests.
1 parent 676eebd commit f99833a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tests/tests.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,16 @@ def x():
192192
self.assertEquals(res, 'tests.tests.x')
193193

194194
def test_lambda(self):
195-
res = get_name_from_obj(lambda:1)
195+
res = get_name_from_obj(lambda: 1)
196196
self.assertEquals(res, 'tests.tests.<lambda>')
197197

198198
def test_class(self):
199-
class A: pass
199+
class A:
200+
pass
200201
res = get_name_from_obj(A)
201202
self.assertEquals(res, 'tests.tests.A')
202203

204+
203205
class SQLPanelTestCase(BaseTestCase):
204206
def test_recording(self):
205207
panel = self.toolbar.get_panel(SQLDebugPanel)
@@ -222,7 +224,7 @@ def test_disable_stacktraces(self):
222224
panel = self.toolbar.get_panel(SQLDebugPanel)
223225
self.assertEquals(len(panel._queries), 0)
224226

225-
with Settings(DEBUG_TOOLBAR_CONFIG={ 'ENABLE_STACKTRACES' : False }):
227+
with Settings(DEBUG_TOOLBAR_CONFIG={'ENABLE_STACKTRACES': False}):
226228
list(User.objects.all())
227229

228230
# ensure query was logged
@@ -242,19 +244,25 @@ def test_queryset_hook(self):
242244
template_panel = self.toolbar.get_panel(TemplateDebugPanel)
243245
sql_panel = self.toolbar.get_panel(SQLDebugPanel)
244246
t = Template("No context variables here!")
245-
c = Context({ 'queryset' : User.objects.all(), 'deep_queryset' : { 'queryset' : User.objects.all() } })
247+
c = Context({
248+
'queryset': User.objects.all(),
249+
'deep_queryset': {
250+
'queryset': User.objects.all(),
251+
}
252+
})
246253
t.render(c)
247254
# ensure the query was NOT logged
248255
self.assertEquals(len(sql_panel._queries), 0)
249256
ctx = template_panel.templates[0]['context'][0]
250-
ctx = eval(ctx) # convert back to Python
251-
self.assertEquals(ctx['queryset'], '<<queryset of auth.User>>')
252-
self.assertEquals(ctx['deep_queryset'], '<<triggers database query>>')
257+
self.assertIn('<<queryset of auth.User>>', ctx)
258+
self.assertIn('<<triggers database query>>', ctx)
259+
253260

254261
def module_func(*args, **kwargs):
255262
"""Used by dispatch tests"""
256263
return 'blah'
257264

265+
258266
class TrackingTestCase(BaseTestCase):
259267
@classmethod
260268
def class_method(cls, *args, **kwargs):

0 commit comments

Comments
 (0)