"""モデルファイルパスのテスト(TDD: RED → GREEN)""" import pytest from pathlib import Path class TestModelPath: """モデルファイルの検索ロジックのテスト""" def test_get_model_path_finds_model_file(self): """モデルファイルが見つかること""" from rock_paper_scissors.detection.hand_detector import _get_model_path # モデルファイルが存在するパスを返す model_path = _get_model_path() assert model_path.exists(), f"Model file not found at {model_path}" assert model_path.name == "hand_landmarker.task" def test_get_model_path_checks_multiple_locations(self): """複数の場所を検索すること""" from rock_paper_scissors.detection.hand_detector import _get_model_path # 正常にパスが返されることを確認 model_path = _get_model_path() assert isinstance(model_path, Path) class TestHandDetectorInitialization: """HandDetectorの初期化テスト""" def test_hand_detector_can_be_instantiated(self): """HandDetectorがインスタンス化できること""" pytest.importorskip("mediapipe") from rock_paper_scissors.detection.hand_detector import HandDetector # インスタンス化が成功すること detector = HandDetector() assert detector is not None # クリーンアップ detector.close() def test_hand_detector_raises_if_mediapipe_not_available(self): """MediaPipeがない場合はエラー""" from rock_paper_scissors.detection import hand_detector # MediaPipeがインストールされている場合はスキップ if hand_detector.MEDIAPIPE_AVAILABLE: pytest.skip("MediaPipe is available, cannot test unavailable case") from rock_paper_scissors.detection.hand_detector import HandDetector with pytest.raises(RuntimeError, match="MediaPipe is not installed"): HandDetector()