"""Shared test fixtures for mckicad tests.""" import tempfile import pytest @pytest.fixture def tmp_project_dir(tmp_path): """Create a temporary directory with a minimal KiCad project structure.""" project_name = "test_project" pro_file = tmp_path / f"{project_name}.kicad_pro" pro_file.write_text('{"meta": {"filename": "test_project.kicad_pro"}}') sch_file = tmp_path / f"{project_name}.kicad_sch" sch_file.write_text("(kicad_sch (version 20230121))") pcb_file = tmp_path / f"{project_name}.kicad_pcb" pcb_file.write_text("(kicad_pcb (version 20230121))") return tmp_path @pytest.fixture def project_path(tmp_project_dir): """Return path to the .kicad_pro file in the temp project.""" return str(tmp_project_dir / "test_project.kicad_pro") @pytest.fixture def schematic_path(tmp_project_dir): """Return path to the .kicad_sch file in the temp project.""" return str(tmp_project_dir / "test_project.kicad_sch") @pytest.fixture def tmp_output_dir(): """Create a temporary output directory.""" with tempfile.TemporaryDirectory(prefix="mckicad_test_") as d: yield d @pytest.fixture(autouse=True) def _set_test_search_paths(tmp_project_dir, monkeypatch): """Point KICAD_SEARCH_PATHS at the temp project directory for all tests.""" monkeypatch.setenv("KICAD_SEARCH_PATHS", str(tmp_project_dir))