File size: 1,386 Bytes
4c75661 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | """κ²½λ‘ ν΄μ β μ°μ μμμ μ€λ₯ λ©μμ§."""
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
|