kicad-mcp/tests/conftest.py
Ryan Malloy 4ae38fed59 Rebuild on FastMCP 3 with src-layout and kicad-sch-api integration
Migrate from FastMCP 2.14.5 to 3.1.0 with complete architectural
overhaul. Adopt src-layout packaging, lazy config functions to
eliminate .env race condition, and decorator-based tool registration.

Consolidate 14 tool modules into 8 focused modules (33 tools total).
Add 9 new schematic tools via kicad-sch-api for creating and
manipulating .kicad_sch files. Drop pandas dependency (BOM uses
stdlib csv). Remove ~17k lines of stubs, over-engineering, and
dead code.

All checks pass: ruff clean, mypy 0 errors, 17/17 tests green.
2026-03-03 18:26:54 -07:00

47 lines
1.3 KiB
Python

"""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))