88from debug_toolbar .store import get_store
99from debug_toolbar .toolbar import DebugToolbar
1010
11- from .. import settings as test_settings
1211from ..base import BaseTestCase , IntegrationTestCase
1312
1413rf = RequestFactory ()
@@ -110,14 +109,17 @@ def test_history_headers(self):
110109 request_id = list (get_store ().request_ids ())[0 ]
111110 self .assertEqual (response .headers ["djdt-request-id" ], request_id )
112111
113- @override_settings (
114- DEBUG_TOOLBAR_CONFIG = {"OBSERVE_REQUEST_CALLBACK" : lambda request : False }
115- )
116112 def test_history_headers_unobserved (self ):
117113 """Validate the headers aren't injected from the history panel."""
114+ with self .settings (
115+ DEBUG_TOOLBAR_CONFIG = {"OBSERVE_REQUEST_CALLBACK" : lambda request : False }
116+ ):
117+ DebugToolbar .get_observe_request .cache_clear ()
118+ response = self .client .get ("/json_view/" )
119+ self .assertNotIn ("djdt-request-id" , response .headers )
120+ # Clear it again to avoid conflicting with another test
121+ # Specifically, DebugToolbarLiveTestCase.test_ajax_refresh
118122 DebugToolbar .get_observe_request .cache_clear ()
119- response = self .client .get ("/json_view/" )
120- self .assertNotIn ("djdt-request-id" , response .headers )
121123
122124 def test_history_sidebar (self ):
123125 """Validate the history sidebar view."""
@@ -145,7 +147,9 @@ def test_history_sidebar_includes_history(self):
145147 panel_keys ,
146148 )
147149
148- @override_settings (DEBUG_TOOLBAR_CONFIG = {"RENDER_PANELS" : False })
150+ @override_settings (
151+ DEBUG_TOOLBAR_CONFIG = {"RENDER_PANELS" : False , "RESULTS_CACHE_SIZE" : 1 }
152+ )
149153 def test_history_sidebar_expired_request_id (self ):
150154 """Validate the history sidebar view."""
151155 self .client .get ("/json_view/" )
@@ -158,8 +162,7 @@ def test_history_sidebar_expired_request_id(self):
158162 self .PANEL_KEYS ,
159163 )
160164 # Make enough requests to unset the original
161- for _i in range (test_settings .DEBUG_TOOLBAR_CONFIG ["RESULTS_CACHE_SIZE" ]):
162- self .client .get ("/json_view/" )
165+ self .client .get ("/json_view/" )
163166
164167 # Querying old request_id should return in empty response
165168 data = {"request_id" : request_id , "exclude_history" : True }
0 commit comments