Download tests/test_inference/test_init.py from AntonioJun/workspace: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/datasets/AntonioJun/workspace/resolve/main/tests/test_inference/test_init.py
- Command line
-
hf download hf://datasets/AntonioJun/workspace/tests/test_inference/test_init.py
-
curl -L -o test_init.py https://huggingface.co/datasets/AntonioJun/workspace/resolve/main/tests/test_inference/test_init.py
2.03 kB
| """Tests for inference package path helpers.""" | |
| from pathlib import Path | |
| import pytest | |
| import inference | |
| def test_video_path_finds_exact_dataset_match(tmp_path, monkeypatch): | |
| root = tmp_path / "VSI-Bench" | |
| video = root / "scannet" / "scene1.mp4" | |
| video.parent.mkdir(parents=True) | |
| video.write_bytes(b"fake video") | |
| monkeypatch.setattr(inference, "VSI_ROOT", root) | |
| assert inference.video_path("scene1") == str(video) | |
| assert inference.video_path("scene1", "scannet") == str(video) | |
| def test_video_path_reports_missing_unknown_and_ambiguous_datasets( | |
| tmp_path, monkeypatch | |
| ): | |
| root = tmp_path / "VSI-Bench" | |
| for dataset in ("scannet", "arkitscenes"): | |
| path = root / dataset / "scene1.mp4" | |
| path.parent.mkdir(parents=True, exist_ok=True) | |
| path.write_bytes(b"fake video") | |
| monkeypatch.setattr(inference, "VSI_ROOT", root) | |
| with pytest.raises(ValueError, match="unknown VSI dataset"): | |
| inference.video_path("scene1", "badset") | |
| with pytest.raises(RuntimeError, match="multiple datasets"): | |
| inference.video_path("scene1") | |
| with pytest.raises(FileNotFoundError, match="searched"): | |
| inference.video_path("missing", "scannet") | |
| def test_cache_dir_helpers_validate_axes_and_include_dimensions(tmp_path, monkeypatch): | |
| monkeypatch.setattr(inference, "CACHE_ROOT", tmp_path) | |
| assert inference.model_cache_dir( | |
| "depth-anything-3", "uniform", 16, "metric" | |
| ) == str(tmp_path / "depth-anything-3" / "metric" / "frames" / "uniform" / "16") | |
| assert inference.sam3_cache_dir("no tracking", "selective", 8) == str( | |
| tmp_path / "sam3" / "no tracking" / "frames" / "selective" / "8" | |
| ) | |
| assert inference.parse_sam3_frame_mode("uniform-tracking") == ( | |
| "uniform", | |
| "tracking", | |
| ) | |
| with pytest.raises(ValueError, match="frame count"): | |
| inference.model_cache_dir("x", "uniform", 0) | |
| with pytest.raises(ValueError, match="unknown tracking"): | |
| inference.sam3_cache_dir("bad", "uniform") | |