Spaces:
Running on Zero
Running on Zero
Download tests/test_scaffold.py from WolfDavid/japanese-learning-avatar: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/WolfDavid/japanese-learning-avatar/resolve/f7e73d2aec50cd58e583c49da86b2c0de1485772/tests/test_scaffold.py
- Command line
-
hf download hf://spaces/WolfDavid/japanese-learning-avatar@f7e73d2aec50cd58e583c49da86b2c0de1485772/tests/test_scaffold.py
-
curl -L -o test_scaffold.py https://huggingface.co/spaces/WolfDavid/japanese-learning-avatar/resolve/f7e73d2aec50cd58e583c49da86b2c0de1485772/tests/test_scaffold.py
1.84 kB
| """Proves the toolchain works before any real code exists.""" | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| def test_python_version_matches_space_runtime(): | |
| assert sys.version_info[:2] == (3, 12), ( | |
| "ZeroGPU provides only Python 3.10.13 and 3.12.12; this project pins 3.12.12" | |
| ) | |
| def test_package_importable(): | |
| import japanese_avatar | |
| assert japanese_avatar.__version__ | |
| def test_ruff_and_pytest_configured(): | |
| import tomllib | |
| cfg = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8")) | |
| assert cfg["tool"]["ruff"]["target-version"] == "py312" | |
| assert "pytest" in cfg["tool"] | |
| def test_lfs_armed_before_any_binary_lands(): | |
| """Plans 01-01 and 01-04 commit tens of megabytes. A non-LFS push of that size is rejected.""" | |
| for path in ("avatar/assets/tutor.vrm", "voicevox/model/zundamon.vvm", "tests/fixtures/x.wav"): | |
| out = subprocess.run( | |
| ["git", "check-attr", "filter", "--", path], capture_output=True, text=True, check=True | |
| ).stdout | |
| assert "filter: lfs" in out, f"{path} is not LFS-tracked; see .gitattributes" | |
| def test_non_speech_fixtures_exist_and_are_30s(silence_wav, cafe_noise_wav): | |
| from tests.conftest import wav_duration_seconds | |
| for p in (silence_wav, cafe_noise_wav): | |
| assert p.exists(), p | |
| assert abs(wav_duration_seconds(p) - 30.0) < 0.01 | |
| def test_cafe_noise_is_loud_enough_to_defeat_an_rms_only_gate(cafe_noise_wav): | |
| """If this fixture were quiet, plan 01-07's noise-rejection test would pass trivially.""" | |
| import wave | |
| import numpy as np | |
| with wave.open(str(cafe_noise_wav), "rb") as w: | |
| pcm = np.frombuffer(w.readframes(w.getnframes()), dtype="<i2").astype(np.float64) / 32768.0 | |
| assert float(np.sqrt(np.mean(pcm**2))) > 0.02, "noise fixture too quiet to be a real test" | |