Description
_FakeScorer and _make_state are copy-pasted across three test files with no shared fixture:
tests/test_commands.py
tests/test_game_state.py
tests/test_overlay.py
This violates DRY and means any change to GameState's constructor signature requires updates in three places.
Fix
Create tests/conftest.py with shared pytest fixtures:
# tests/conftest.py
import pytest
from game.state import GameState
class _FakeScorer:
def score_guess(self, guess: str, target: str) -> float | None:
if not target:
return None
return min(1.0, len(guess) / len(target))
@pytest.fixture()
def fake_scorer() -> _FakeScorer:
return _FakeScorer()
@pytest.fixture()
def game_state() -> GameState:
return GameState()
@pytest.fixture()
def game_state_with_scorer() -> GameState:
return GameState(scorer=_FakeScorer())
Then remove the duplicate definitions from the three test files and inject the fixtures via function parameters.
Identified by
🧪 [Tech] Tester
Description
_FakeScorerand_make_stateare copy-pasted across three test files with no shared fixture:tests/test_commands.pytests/test_game_state.pytests/test_overlay.pyThis violates DRY and means any change to
GameState's constructor signature requires updates in three places.Fix
Create
tests/conftest.pywith shared pytest fixtures:Then remove the duplicate definitions from the three test files and inject the fixtures via function parameters.
Identified by
🧪
[Tech] Tester