Skip to content

Commit 7ef85b0

Browse files
committed
a fix
1 parent 2b2c210 commit 7ef85b0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/test_compat.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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])

0 commit comments

Comments
 (0)