Skip to content

Commit d4b0317

Browse files
proboscisClaude
and
Claude
committed
Fix type annotations in reawaitable test files
- Add proper type annotations to variables in test files - Restructure tests to avoid unreachable statements - Split test_reawaitable_create_lock into separate test functions - Fix flake8 and mypy issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e0055b9 commit d4b0317

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

tests/test_primitives/test_reawaitable/test_reawaitable_full_coverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def test_reawaitable_lock_creation():
2222
assert instance._lock is None
2323

2424
# Await to trigger lock creation
25-
result = await instance
25+
result: str = await instance
2626
assert result == 'value'
2727

2828
# Verify lock is created

tests/test_primitives/test_reawaitable/test_reawaitable_lock.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,27 @@ async def _test_coro() -> str:
1414

1515

1616
@pytest.mark.anyio
17-
async def test_reawaitable_create_lock():
18-
"""Test that ReAwaitable correctly creates the lock when needed."""
19-
# Create ReAwaitable instance
17+
async def test_reawaitable_lock_none_initially():
18+
"""Test that ReAwaitable has no lock initially."""
2019
reawait = ReAwaitable(_test_coro())
21-
22-
# The lock should be None initially
2320
assert reawait._lock is None
24-
25-
# Await the coroutine once
26-
result1 = await reawait
27-
28-
# The lock should be created
21+
22+
23+
@pytest.mark.anyio
24+
async def test_reawaitable_creates_lock():
25+
"""Test that ReAwaitable creates lock after first await."""
26+
reawait = ReAwaitable(_test_coro())
27+
await reawait
2928
assert reawait._lock is not None
30-
assert result1 == 'test'
31-
32-
# Await again, should use the same lock
33-
result2 = await reawait
34-
assert result2 == 'test'
29+
30+
31+
@pytest.mark.anyio
32+
async def test_reawait_twice():
33+
"""Test awaiting the same ReAwaitable twice."""
34+
reawait = ReAwaitable(_test_coro())
35+
first: str = await reawait
36+
second: str = await reawait
37+
assert first == second == 'test'
3538

3639

3740
@pytest.mark.anyio
@@ -47,6 +50,6 @@ async def test_is_in_trio_context():
4750
"""Test trio context detection."""
4851
# Since we might be running in either context,
4952
# we just check the function runs without errors
50-
result = _is_in_trio_context()
53+
result: bool = _is_in_trio_context()
5154
# Result will depend on which backend anyio is using
5255
assert isinstance(result, bool)

0 commit comments

Comments
 (0)