ci: add strict-no-cover to detect unnecessary coverage pragmas (#1897)
This commit is contained in:
parent
3cfdea0e97
commit
a7ddfdae07
5 changed files with 355 additions and 358 deletions
|
|
@ -102,7 +102,7 @@ async def test_lifespan_cleanup_executed():
|
|||
|
||||
# Give server a moment to complete cleanup
|
||||
with anyio.move_on_after(5.0):
|
||||
while not Path(cleanup_marker).exists(): # pragma: no cover
|
||||
while not Path(cleanup_marker).exists(): # pragma: lax no cover
|
||||
await anyio.sleep(0.1)
|
||||
|
||||
# Verify cleanup marker was created - this works now that stdio_client
|
||||
|
|
@ -113,9 +113,9 @@ async def test_lifespan_cleanup_executed():
|
|||
finally:
|
||||
# Clean up files
|
||||
for path in [server_script, startup_marker, cleanup_marker]:
|
||||
try: # pragma: no cover
|
||||
try: # pragma: lax no cover
|
||||
Path(path).unlink()
|
||||
except FileNotFoundError: # pragma: no cover
|
||||
except FileNotFoundError: # pragma: lax no cover
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ async def test_stdin_close_triggers_cleanup():
|
|||
await anyio.sleep(0.1)
|
||||
|
||||
# Check if process is still running
|
||||
if hasattr(process, "returncode") and process.returncode is not None: # pragma: no cover
|
||||
if hasattr(process, "returncode") and process.returncode is not None: # pragma: lax no cover
|
||||
pytest.fail(f"Server process exited with code {process.returncode}")
|
||||
|
||||
assert Path(startup_marker).exists(), "Server startup marker not created"
|
||||
|
|
@ -217,14 +217,14 @@ async def test_stdin_close_triggers_cleanup():
|
|||
try:
|
||||
with anyio.fail_after(5.0): # Increased from 2.0 to 5.0
|
||||
await process.wait()
|
||||
except TimeoutError: # pragma: no cover
|
||||
except TimeoutError: # pragma: lax no cover
|
||||
# If it doesn't exit after stdin close, terminate it
|
||||
process.terminate()
|
||||
await process.wait()
|
||||
|
||||
# Check if cleanup ran
|
||||
with anyio.move_on_after(5.0):
|
||||
while not Path(cleanup_marker).exists(): # pragma: no cover
|
||||
while not Path(cleanup_marker).exists(): # pragma: lax no cover
|
||||
await anyio.sleep(0.1)
|
||||
|
||||
# Verify the cleanup ran - stdin closure enables graceful shutdown
|
||||
|
|
@ -234,7 +234,7 @@ async def test_stdin_close_triggers_cleanup():
|
|||
finally:
|
||||
# Clean up files
|
||||
for path in [server_script, startup_marker, cleanup_marker]:
|
||||
try: # pragma: no cover
|
||||
try: # pragma: lax no cover
|
||||
Path(path).unlink()
|
||||
except FileNotFoundError: # pragma: no cover
|
||||
except FileNotFoundError: # pragma: lax no cover
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ async def test_resource_templates():
|
|||
assert len(templates) == 2
|
||||
|
||||
# Verify template details
|
||||
greeting_template = next(t for t in templates if t.name == "get_greeting") # pragma: no cover
|
||||
greeting_template = next(t for t in templates if t.name == "get_greeting")
|
||||
assert greeting_template.uri_template == "greeting://{name}"
|
||||
assert greeting_template.description == "Get a personalized greeting"
|
||||
|
||||
profile_template = next(t for t in templates if t.name == "get_user_profile") # pragma: no cover
|
||||
profile_template = next(t for t in templates if t.name == "get_user_profile")
|
||||
assert profile_template.uri_template == "users://{user_id}/profile"
|
||||
assert profile_template.description == "Dynamic user data"
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ def check_logs_for_race_condition_errors(caplog: pytest.LogCaptureFixture, test_
|
|||
# Check for specific race condition errors in logs
|
||||
errors_found: list[str] = []
|
||||
|
||||
for record in caplog.records: # pragma: no cover
|
||||
for record in caplog.records: # pragma: lax no cover
|
||||
message = record.getMessage()
|
||||
if "ClosedResourceError" in message:
|
||||
errors_found.append("ClosedResourceError")
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ async def test_notification_validation_error(tmp_path: Path):
|
|||
# proving server is still responsive
|
||||
result = await session.call_tool("fast", read_timeout_seconds=None)
|
||||
assert result.content == [TextContent(type="text", text="fast 3")]
|
||||
scope.cancel() # pragma: no cover
|
||||
scope.cancel() # pragma: lax no cover
|
||||
|
||||
# Run server and client in separate task groups to avoid cancellation
|
||||
server_writer, server_reader = anyio.create_memory_object_stream[SessionMessage](1)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ async def test_malformed_initialize_request_does_not_crash_server():
|
|||
|
||||
except anyio.WouldBlock: # pragma: no cover
|
||||
pytest.fail("No response received - server likely crashed")
|
||||
finally: # pragma: no cover
|
||||
finally: # pragma: lax no cover
|
||||
# Close all streams to ensure proper cleanup
|
||||
await read_send_stream.aclose()
|
||||
await write_send_stream.aclose()
|
||||
|
|
@ -143,7 +143,7 @@ async def test_multiple_concurrent_malformed_requests():
|
|||
assert isinstance(response, JSONRPCError)
|
||||
assert response.id == f"malformed_{i}"
|
||||
assert response.error.code == INVALID_PARAMS
|
||||
finally: # pragma: no cover
|
||||
finally: # pragma: lax no cover
|
||||
# Close all streams to ensure proper cleanup
|
||||
await read_send_stream.aclose()
|
||||
await write_send_stream.aclose()
|
||||
|
|
|
|||
Loading…
Reference in a new issue