@@ -110,6 +110,18 @@ def test_low_level_cache_view(self):
110110 self .client .get ("/cached_low_level_view/" )
111111 self .assertEqual (len (self .toolbar .get_panel_by_id ("CachePanel" ).calls ), 3 )
112112
113+ def test_cache_disable_instrumentation (self ):
114+ """
115+ Verify that middleware cache usages before and after
116+ DebugToolbarMiddleware are not counted.
117+ """
118+ self .assertIsNone (cache .set ("UseCacheAfterToolbar.before" , None ))
119+ self .assertIsNone (cache .set ("UseCacheAfterToolbar.after" , None ))
120+ self .client .get ("/execute_sql/" )
121+ self .assertEqual (cache .get ("UseCacheAfterToolbar.before" ), 1 )
122+ self .assertEqual (cache .get ("UseCacheAfterToolbar.after" ), 1 )
123+ self .assertEqual (len (self .toolbar .get_panel_by_id ("CachePanel" ).calls ), 0 )
124+
113125 def test_is_toolbar_request (self ):
114126 self .request .path = "/__debug__/render_panel/"
115127 self .assertTrue (self .toolbar .is_toolbar_request (self .request ))
@@ -384,7 +396,7 @@ def test_view_returns_template_response(self):
384396 self .assertEqual (response .status_code , 200 )
385397
386398 @override_settings (DEBUG_TOOLBAR_CONFIG = {"DISABLE_PANELS" : set ()})
387- def test_incercept_redirects (self ):
399+ def test_intcercept_redirects (self ):
388400 response = self .client .get ("/redirect/" )
389401 self .assertEqual (response .status_code , 200 )
390402 # Link to LOCATION header.
@@ -561,18 +573,6 @@ def test_django_cached_template_loader(self):
561573 )
562574 )
563575
564- def test_cache_disable_instrumentation (self ):
565- """
566- Verify that middleware cache usages before and after
567- DebugToolbarMiddleware are not counted.
568- """
569- self .assertIsNone (cache .set ("UseCacheAfterToolbar.before" , None ))
570- self .assertIsNone (cache .set ("UseCacheAfterToolbar.after" , None ))
571- self .get ("/execute_sql/" )
572- self .assertEqual (cache .get ("UseCacheAfterToolbar.before" ), 1 )
573- self .assertEqual (cache .get ("UseCacheAfterToolbar.after" ), 1 )
574- self .assertEqual (len (self .toolbar .get_panel_by_id ("CachePanel" ).calls ), 0 )
575-
576576 def test_sql_action_and_go_back (self ):
577577 self .get ("/execute_sql/" )
578578 sql_panel = self .selenium .find_element_by_id ("SQLPanel" )
0 commit comments