"""Unit tests for --workdir CLI argument handling.""" import subprocess import sys from pathlib import Path class TestWorkdirCLI: def test_missing_workdir_argument(self): """CLI should exit with error when --workdir is not provided.""" result = subprocess.run( [sys.executable, "main.py"], capture_output=True, text=True, ) assert result.returncode != 0 assert "--workdir argument is required" in result.stderr def test_nonexistent_workdir(self, tmp_path): """CLI should exit with error when --workdir path doesn't exist.""" nonexistent = tmp_path / "does_not_exist" result = subprocess.run( [sys.executable, "main.py", "--workdir", str(nonexistent)], capture_output=True, text=True, ) assert result.returncode != 0 assert "Workdir does not exist" in result.stderr def test_workdir_is_file_not_directory(self, tmp_path): """CLI should exit with error when --workdir is a file, not a directory.""" file_path = tmp_path / "afile.txt" file_path.write_text("I am a file") result = subprocess.run( [sys.executable, "main.py", "--workdir", str(file_path)], capture_output=True, text=True, ) assert result.returncode != 0 assert "Workdir is not a directory" in result.stderr