Skip to content

Commit e0055b9

Browse files
proboscisClaude
and
Claude
committed
Fix flake8 issues in reawaitable test files
- Move nested coroutine functions to module level with proper naming - Fix variable naming to comply with style guidelines - Maintain test coverage for lock creation and async context detection 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5775111 commit e0055b9

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

tests/test_primitives/test_reawaitable/test_reawaitable_full_coverage.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
)
88

99

10+
async def _test_coro() -> str:
11+
"""Test coroutine for ReAwaitable tests."""
12+
return 'value'
13+
14+
1015
@pytest.mark.anyio
1116
async def test_reawaitable_lock_creation():
1217
"""Test the _create_lock method for different contexts."""
13-
async def sample_coro() -> str:
14-
return 'value'
15-
1618
# Create a ReAwaitable instance
17-
instance = ReAwaitable(sample_coro())
19+
instance = ReAwaitable(_test_coro())
1820

1921
# Test the lock is initially None
2022
assert instance._lock is None
@@ -31,16 +33,17 @@ async def sample_coro() -> str:
3133
# We're relying on pragmas now for this purpose
3234

3335

36+
@reawaitable
37+
async def _test_multiply(num: int) -> int:
38+
"""Test coroutine for decorator tests."""
39+
return num * 2
40+
41+
3442
@pytest.mark.anyio
3543
async def test_reawaitable_decorator():
3644
"""Test the reawaitable decorator."""
37-
# Define a test coroutine
38-
@reawaitable
39-
async def test_func(value: int) -> int:
40-
return value * 2
41-
4245
# Call the decorated function
43-
result = test_func(5)
46+
result = _test_multiply(5)
4447

4548
# Verify it can be awaited multiple times
4649
assert await result == 10

tests/test_primitives/test_reawaitable/test_reawaitable_lock.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
)
99

1010

11+
async def _test_coro() -> str:
12+
"""Test coroutine for ReAwaitable tests."""
13+
return 'test'
14+
15+
1116
@pytest.mark.anyio
1217
async def test_reawaitable_create_lock():
1318
"""Test that ReAwaitable correctly creates the lock when needed."""
14-
async def sample_coroutine() -> str:
15-
return 'test'
16-
1719
# Create ReAwaitable instance
18-
reawait = ReAwaitable(sample_coroutine())
20+
reawait = ReAwaitable(_test_coro())
1921

2022
# The lock should be None initially
2123
assert reawait._lock is None

0 commit comments

Comments
 (0)