From 8fbee01c11e14ea88596812705855e9034b3181b Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Sat, 7 Feb 2026 16:17:41 -0500 Subject: [PATCH] Use contextlib.suppress for cleaner exception handling --- tests/test_server.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_server.py b/tests/test_server.py index fdcb79e..d086d0f 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -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