Skip to content

Commit 4d646e9

Browse files
committed
Fix code style issues in tests
1 parent 3699bef commit 4d646e9

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

Diff for: tests/test_primitives/test_reawaitable/test_reawaitable_concurrency.py

+25-25
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,31 @@ async def sample_coro():
99
return 'done'
1010

1111

12+
async def await_helper(awaitable_obj):
13+
"""Helper to await objects in tasks."""
14+
return await awaitable_obj
15+
16+
1217
@pytest.mark.anyio
1318
async def test_concurrent_awaitable():
19+
"""Test that ReAwaitable works with concurrent awaits."""
1420
test_target = ReAwaitable(sample_coro())
1521

16-
async def await_reawaitable():
17-
return await test_target
1822
async with anyio.create_task_group() as tg:
19-
task1 = tg.start_soon(await_reawaitable)
20-
task2 = tg.start_soon(await_reawaitable)
23+
tg.start_soon(await_helper, test_target)
24+
tg.start_soon(await_helper, test_target)
2125

2226

23-
@pytest.mark.anyio
24-
async def test_reawaitable_decorator():
25-
"""Test the reawaitable decorator with concurrent awaits."""
27+
async def _test_coro(): # noqa: WPS430
28+
await anyio.sleep(0.1)
29+
return "decorated"
2630

27-
@reawaitable
28-
async def decorated_coro():
29-
await anyio.sleep(0.1)
30-
return "decorated"
3131

32-
instance = decorated_coro()
32+
@pytest.mark.anyio # noqa: WPS210
33+
async def test_reawaitable_decorator():
34+
"""Test the reawaitable decorator with concurrent awaits."""
35+
decorated = reawaitable(_test_coro)
36+
instance = decorated()
3337

3438
# Test multiple awaits
3539
result1 = await instance
@@ -39,26 +43,22 @@ async def decorated_coro():
3943
assert result1 == result2
4044

4145
# Test concurrent awaits
42-
async def await_decorated():
43-
return await instance
44-
4546
async with anyio.create_task_group() as tg:
46-
task1 = tg.start_soon(await_decorated)
47-
task2 = tg.start_soon(await_decorated)
47+
tg.start_soon(await_helper, instance)
48+
tg.start_soon(await_helper, instance)
4849

4950

5051
@pytest.mark.anyio
5152
async def test_reawaitable_repr():
5253
"""Test the __repr__ method of ReAwaitable."""
53-
54-
async def test_func():
54+
55+
async def test_func(): # noqa: WPS430
5556
return 1
56-
57+
5758
coro = test_func()
58-
reawaitable = ReAwaitable(coro)
59-
59+
target = ReAwaitable(coro)
60+
6061
# Test the representation
61-
assert repr(reawaitable) == repr(coro)
62-
62+
assert repr(target) == repr(coro)
6363
# Ensure the coroutine is properly awaited
64-
await reawaitable
64+
await target

0 commit comments

Comments
 (0)