vkgs-sim / tests /test_paths.py
kimjunhan's picture
Add files using upload-large-folder tool
4c75661 verified
Raw History Blame Contribute Delete
1.39 kB
"""경둜 해석 β€” μš°μ„ μˆœμœ„μ™€ 였λ₯˜ λ©”μ‹œμ§€."""
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