tests: cmd_stats tests no longer hit the network
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWxdzckyBH7fEbPywpr
This commit is contained in:
Krzysztof Rudnicki 2026-11-02 09:31:10 +01:00
parent 2e66502abc
commit bfa4a6260f

View File

@ -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",