Use contextlib.suppress for cleaner exception handling

This commit is contained in:
Jared Miller 2026-02-07 16:17:41 -05:00
parent 075a6ce303
commit 8fbee01c11
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -1,6 +1,7 @@
"""Tests for the server module."""
import asyncio
import contextlib
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
@ -108,7 +109,7 @@ def test_load_world_config_missing():
def test_tick_constants():
"""Tick rate and interval are configured correctly."""
assert server.TICK_RATE == 10
assert server.TICK_INTERVAL == pytest.approx(0.1)
assert pytest.approx(0.1) == server.TICK_INTERVAL
def test_game_loop_exists():
@ -124,9 +125,7 @@ async def test_game_loop_calls_clear_expired():
task = asyncio.create_task(server.game_loop())
await asyncio.sleep(0.25)
task.cancel()
try:
with contextlib.suppress(asyncio.CancelledError):
await task
except asyncio.CancelledError:
pass
assert mock_clear.call_count >= 1