from __future__ import annotations import subprocess import sys from pathlib import Path import pytest CLI_COMMANDS = ["mouse-collect", "mouse-train", "mouse-visualize"] @pytest.mark.parametrize("command", CLI_COMMANDS) def test_cli_help(command: str) -> None: """Every CLI must respond to --help with exit 0 and an argparse usage line.""" result = subprocess.run( [command, "--help"], capture_output=True, text=True, check=False, ) assert result.returncode == 0, result.stderr assert "usage:" in result.stdout def test_visualize_no_show_produces_png(tmp_path: Path) -> None: save_path = tmp_path / "out.png" result = subprocess.run( [ "mouse-visualize", "--no-show", "--seed", "1", "--n-trajectories", "3", "--n-interp", "20", "--save", str(save_path), ], capture_output=True, text=True, check=False, ) assert result.returncode == 0, result.stderr assert save_path.exists() assert save_path.stat().st_size > 1000 def test_visualize_module_invocation(tmp_path: Path) -> None: """The module is also runnable via `python -m mouse_control.visualize`.""" save_path = tmp_path / "out.png" result = subprocess.run( [ sys.executable, "-m", "mouse_control.visualize", "--no-show", "--seed", "2", "--n-trajectories", "2", "--save", str(save_path), ], capture_output=True, text=True, check=False, ) assert result.returncode == 0, result.stderr assert save_path.exists()