项目文件夹

文件
wehub-resource-sync 2c632336aa
CI / Viewer CI (push) Successful in 13m37s
CI / Core CI (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:38 +08:00

41 行
1.2 KiB
Python

from __future__ import annotations
import re
from pathlib import Path
import pytest
import sdk
_PYTHON_FENCE_RE = re.compile(r"```python\n(.*?)```", re.DOTALL)
_EXAMPLE_PATHS = (
"sdk/_examples/base/jet_engine_with_smooth_nacelle_dense_front_fan.md",
"sdk/_examples/base/atv_quad_bike_with_front_steering_and_suspension.md",
"sdk/_examples/base/artisan_stand_mixer_with_tilt_head_balloon_whisk_and_articulated_controls.md",
)
def _repo_root() -> Path:
return Path(__file__).resolve().parents[2]
def _extract_python_fence(path: Path) -> str:
match = _PYTHON_FENCE_RE.search(path.read_text(encoding="utf-8"))
if match is None:
raise AssertionError(f"No Python fence found in {path}")
return match.group(1)
@pytest.mark.parametrize("relative_path", _EXAMPLE_PATHS)
def test_base_example_executes_and_passes_sdk_checks(tmp_path: Path, relative_path: str) -> None:
path = _repo_root() / relative_path
namespace = {"__file__": str(tmp_path / f"{path.stem}.py")}
exec(_extract_python_fence(path), namespace)
object_model = namespace["object_model"]
ctx = sdk.TestContext(object_model)
ctx.check_model_valid()
ctx.check_mesh_assets_ready()