"""Smoke tests for the wood-* tool generator (the fragile external layer). Loads the generator without running it (writes are under main()) and checks every generated tool body is valid, portable Python.""" import importlib.util from pathlib import Path import pytest pytest.importorskip("yaml") _SCRIPT = Path(__file__).resolve().parent.parent / "scripts" / "gen_wood_tools.py" def _load(): spec = importlib.util.spec_from_file_location("gen_wood_tools", _SCRIPT) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) # safe: file-writing is under main() return mod def test_every_tool_body_compiles_and_is_portable(): mod = _load() assert mod.TOOLS and "wood-place" in mod.TOOLS for name, spec in mod.TOOLS.items(): compile(spec["code"], name, "exec") # valid Python assert "ws + [" in spec["code"] or "ws +[" in spec["code"] # uses resolved prefix assert "PycharmProjects" not in spec["code"] # no hardcoded local path def test_generator_resolves_woodshop_at_runtime(): mod = _load() assert "shutil.which('woodshop')" in mod.WS assert "PycharmProjects" not in mod.WS