From bfa4a6260fd7160b23befeb3e707c70d771f1649 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 2 Nov 2026 09:31:10 +0100 Subject: [PATCH] tests: cmd_stats tests no longer hit the network Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WzxdWxdzckyBH7fEbPywpr --- .../tests/test_stats_cmd_stats.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/steam_backlog_enforcer/tests/test_stats_cmd_stats.py b/steam_backlog_enforcer/tests/test_stats_cmd_stats.py index 6554c5c..e426c8b 100644 --- a/steam_backlog_enforcer/tests/test_stats_cmd_stats.py +++ b/steam_backlog_enforcer/tests/test_stats_cmd_stats.py @@ -2,8 +2,11 @@ from __future__ import annotations +from typing import TYPE_CHECKING from unittest.mock import patch +import pytest + from steam_backlog_enforcer._stats import ( _GameTimes, cmd_stats, @@ -12,9 +15,20 @@ from steam_backlog_enforcer.config import Config, State from steam_backlog_enforcer.protondb import ProtonDBRating from steam_backlog_enforcer.steam_api import GameInfo +if TYPE_CHECKING: + from collections.abc import Iterator + _PKG = "steam_backlog_enforcer._stats" +@pytest.fixture(autouse=True) +def _no_live_refresh() -> Iterator[None]: + """cmd_stats must not hit Steam or HLTB: unmocked, each test cost ~2 s.""" + refresh = f"{_PKG}._refresh_recently_played_completions" + with patch(refresh, lambda g, _c: g), patch(f"{_PKG}._print_worst_example"): + yield + + def _game( app_id: int = 1, name: str = "G",