Skip to content

Commit a354771

Browse files
committed
remove warnings using the async loop fixture
1 parent df22d58 commit a354771

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

packages/service-library/tests/test_pools.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from asyncio import BaseEventLoop
1+
import asyncio
22
from concurrent.futures import ProcessPoolExecutor
33

44
from servicelib.pools import (
@@ -11,17 +11,25 @@ def return_int_one() -> int:
1111
return 1
1212

1313

14-
async def test_default_thread_pool_executor(event_loop: BaseEventLoop) -> None:
15-
assert await event_loop.run_in_executor(None, return_int_one) == 1
14+
async def test_default_thread_pool_executor() -> None:
15+
assert await asyncio.get_running_loop().run_in_executor(None, return_int_one) == 1
1616

1717

18-
async def test_blocking_process_pool_executor(event_loop: BaseEventLoop) -> None:
19-
assert await event_loop.run_in_executor(ProcessPoolExecutor(), return_int_one) == 1
18+
async def test_blocking_process_pool_executor() -> None:
19+
assert (
20+
await asyncio.get_running_loop().run_in_executor(
21+
ProcessPoolExecutor(), return_int_one
22+
)
23+
== 1
24+
)
2025

2126

22-
async def test_non_blocking_process_pool_executor(event_loop: BaseEventLoop) -> None:
27+
async def test_non_blocking_process_pool_executor() -> None:
2328
with non_blocking_process_pool_executor() as executor:
24-
assert await event_loop.run_in_executor(executor, return_int_one) == 1
29+
assert (
30+
await asyncio.get_running_loop().run_in_executor(executor, return_int_one)
31+
== 1
32+
)
2533

2634

2735
async def test_same_pool_instances() -> None:
@@ -36,9 +44,12 @@ async def test_different_pool_instances() -> None:
3644
assert first != second
3745

3846

39-
async def test_non_blocking_thread_pool_executor(event_loop: BaseEventLoop) -> None:
47+
async def test_non_blocking_thread_pool_executor() -> None:
4048
with non_blocking_thread_pool_executor() as executor:
41-
assert await event_loop.run_in_executor(executor, return_int_one) == 1
49+
assert (
50+
await asyncio.get_running_loop().run_in_executor(executor, return_int_one)
51+
== 1
52+
)
4253

4354

4455
async def test_same_thread_pool_instances() -> None:

0 commit comments

Comments
 (0)