File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ def test_shutdown_default_executor_timeout_warns_and_falls_back_to_nowait(
152152 async def main () -> tuple [list [bool ], list [str ]]:
153153 loop = asyncio .get_running_loop ()
154154 calls = []
155+ messages = []
155156
156157 class DummyExecutor :
157158 def shutdown (self , wait ):
@@ -160,10 +161,13 @@ def shutdown(self, wait):
160161 time .sleep (0.2 )
161162
162163 loop .set_default_executor (DummyExecutor ())
163- with warnings .catch_warnings (record = True ) as caught :
164- warnings .simplefilter ("always" )
164+ def capture_warning (message , category = None , stacklevel = 1 , source = None ):
165+ messages .append (str (message ))
166+ return None
167+
168+ with mock .patch .object (warnings , "warn" , side_effect = capture_warning ):
165169 await loop .shutdown_default_executor (timeout = 0.01 )
166- return calls , [ str ( item . message ) for item in caught ]
170+ return calls , messages
167171
168172 calls , messages = rsloop .run (main ())
169173 self .assertEqual (calls , [True , False ])
You can’t perform that action at this time.
0 commit comments