"""경로 해석 — 우선순위와 오류 메시지.""" import pytest from nusim.paths import DatasetPaths, nuscenes_root def _fake_root(tmp_path): for d in ("v1.0-trainval", "samples", "maps"): (tmp_path / d).mkdir() return tmp_path def test_explicit_wins(tmp_path, monkeypatch): root = _fake_root(tmp_path) monkeypatch.setenv("NUSCENES_ROOT", "/does/not/exist") assert nuscenes_root(root) == root def test_env_var_used(tmp_path, monkeypatch): root = _fake_root(tmp_path) monkeypatch.setenv("NUSCENES_ROOT", str(root)) assert nuscenes_root() == root def test_missing_root_lists_what_it_tried(tmp_path, monkeypatch): monkeypatch.setenv("NUSCENES_ROOT", str(tmp_path / "nope")) monkeypatch.setattr("nusim.paths._ROOT_CANDIDATES", ()) monkeypatch.setattr("nusim.paths.workspace_root", lambda: tmp_path) with pytest.raises(FileNotFoundError) as e: nuscenes_root() # 사용자가 무엇을 고쳐야 하는지 알 수 있어야 한다 assert "nope" in str(e.value) assert "NUSCENES_ROOT" in str(e.value) def test_subpaths(tmp_path): root = _fake_root(tmp_path) d = DatasetPaths(root=root) assert d.meta == root / "v1.0-trainval" assert d.map_expansion == root / "maps" / "expansion" checks = d.check() assert checks["meta"][0] is True assert checks["can_bus"][0] is False