Use contextlib.suppress for cleaner exception handling
This commit is contained in:
parent
075a6ce303
commit
8fbee01c11
1 changed files with 3 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue