Skip to content

Commit 07d4852

Browse files
committed
wait for resource warning
1 parent a2248e7 commit 07d4852

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

test/asynchronous/test_monitor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ async def create_client(self):
5858
return client
5959

6060
async def test_cleanup_executors_on_client_del(self):
61-
with warnings.catch_warnings():
62-
warnings.simplefilter("ignore")
61+
with warnings.catch_warnings(record=True) as w:
62+
warnings.simplefilter("always")
6363
client = await self.create_client()
6464
executors = get_executors(client)
6565
self.assertEqual(len(executors), 4)
@@ -75,6 +75,14 @@ async def test_cleanup_executors_on_client_del(self):
7575
partial(unregistered, ref), f"unregister executor: {name}", timeout=5
7676
)
7777

78+
def resource_warning_caught():
79+
for warning in w:
80+
if isinstance(warning.message, ResourceWarning):
81+
return True
82+
return False
83+
84+
await async_wait_until(resource_warning_caught, "catch resource warning")
85+
7886
async def test_cleanup_executors_on_client_close(self):
7987
client = await self.create_client()
8088
executors = get_executors(client)

test/test_monitor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def create_client(self):
5858
return client
5959

6060
def test_cleanup_executors_on_client_del(self):
61-
with warnings.catch_warnings():
62-
warnings.simplefilter("ignore")
61+
with warnings.catch_warnings(record=True) as w:
62+
warnings.simplefilter("always")
6363
client = self.create_client()
6464
executors = get_executors(client)
6565
self.assertEqual(len(executors), 4)
@@ -73,6 +73,14 @@ def test_cleanup_executors_on_client_del(self):
7373
for ref, name in executor_refs:
7474
wait_until(partial(unregistered, ref), f"unregister executor: {name}", timeout=5)
7575

76+
def resource_warning_caught():
77+
for warning in w:
78+
if isinstance(warning.message, ResourceWarning):
79+
return True
80+
return False
81+
82+
wait_until(resource_warning_caught, "catch resource warning")
83+
7684
def test_cleanup_executors_on_client_close(self):
7785
client = self.create_client()
7886
executors = get_executors(client)

0 commit comments

Comments
 (0)