File tree 2 files changed +17
-10
lines changed 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -334,19 +334,26 @@ def pytest_fixture_setup(fixturedef, request):
334
334
from django .test .utils import CaptureQueriesContext
335
335
from django .db import connection
336
336
337
- with CaptureQueriesContext (connection ) as context :
338
- yield
337
+ _blocking_manager .unblock ()
339
338
340
- querycount = len (context .captured_queries )
339
+ try :
340
+ with CaptureQueriesContext (connection ) as context :
341
+ yield
342
+ except Exception :
343
+ yield
344
+ else :
345
+ querycount = len (context .captured_queries )
341
346
342
- if querycount :
343
- capman = config .pluginmanager .getplugin ('capturemanager' )
344
- capman .suspendcapture ()
347
+ if querycount :
348
+ capman = config .pluginmanager .getplugin ('capturemanager' )
349
+ capman .suspend_global_capture ()
345
350
346
- tw = config .get_terminal_writer ()
347
- tw .write (' (# queries executed: {})' .format (querycount ))
351
+ tw = config .get_terminal_writer ()
352
+ tw .write (' (# of queries executed: {})' .format (querycount ))
348
353
349
- capman .resumecapture ()
354
+ capman .resume_global_capture ()
355
+ finally :
356
+ _blocking_manager .restore ()
350
357
351
358
352
359
@pytest .hookimpl (hookwrapper = True )
Original file line number Diff line number Diff line change @@ -109,4 +109,4 @@ def test_without_queries(one_query):
109
109
'--querycount=5'
110
110
)
111
111
112
- assert '(# queries executed: 1)' in result .stdout .str ()
112
+ assert '(# of queries executed: 1)' in result .stdout .str ()
You can’t perform that action at this time.
0 commit comments