Download code/evaluation/tests/test_cpu_smoke.py from luyu1021/turbot2va-ltx2: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/luyu1021/turbot2va-ltx2/resolve/main/code/evaluation/tests/test_cpu_smoke.py
- Command line
-
hf download hf://luyu1021/turbot2va-ltx2/code/evaluation/tests/test_cpu_smoke.py
-
curl -L -o test_cpu_smoke.py https://huggingface.co/luyu1021/turbot2va-ltx2/resolve/main/code/evaluation/tests/test_cpu_smoke.py
1.67 kB
| import json | |
| import sys | |
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| from unittest.mock import patch | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts")) | |
| from prepare_cpu_smoke import prepare # noqa: E402 | |
| class PrepareCpuSmokeTest(unittest.TestCase): | |
| def test_requires_real_benchmark_index_and_cannot_overwrite(self): | |
| with tempfile.TemporaryDirectory() as tmp: | |
| root = Path(tmp) | |
| video = root / "sample_0.mp4" | |
| video.write_bytes(b"source") | |
| table = root / "table.json" | |
| table.write_text(json.dumps({ | |
| "columns": ["index", "prompt", "local_path"], | |
| "data": [[0, "A prompt", str(video)]], | |
| })) | |
| output = root / "out" | |
| with patch("prepare_cpu_smoke.subprocess.run") as run: | |
| with self.assertRaisesRegex(ValueError, "not unique/present"): | |
| prepare(table, 1, output) | |
| self.assertFalse(output.exists()) | |
| def fake_ffmpeg(command, check): | |
| Path(command[-1]).write_bytes(b"wav") | |
| run.side_effect = fake_ffmpeg | |
| manifest = prepare(table, 0, output) | |
| self.assertEqual(manifest["prompt"], "A prompt") | |
| self.assertEqual(manifest["source_video_sha256"], | |
| __import__("hashlib").sha256(b"source").hexdigest()) | |
| self.assertTrue((output / "javisbench_input.csv").is_file()) | |
| with self.assertRaises(FileExistsError): | |
| prepare(table, 0, output) | |
| if __name__ == "__main__": | |
| unittest.main() | |