Spaces:
Sleeping
Sleeping
Download tests/patch_view/test_audio_cache.py from benhong/blt-patch-view: direct link, hf CLI and curl.
- Browser
- Download file 486 Bytes
-
https://huggingface.co/spaces/benhong/blt-patch-view/resolve/main/tests/patch_view/test_audio_cache.py
- Command line
-
hf download hf://spaces/benhong/blt-patch-view/tests/patch_view/test_audio_cache.py
-
curl -L -o test_audio_cache.py https://huggingface.co/spaces/benhong/blt-patch-view/resolve/main/tests/patch_view/test_audio_cache.py
486 Bytes
| from unittest import mock | |
| import numpy as np | |
| from patch_view import audio | |
| def test_load_audio_file_uses_cache(tmp_path): | |
| fake_audio = np.zeros(10) | |
| audio_file = tmp_path / "sample.wav" | |
| audio_file.write_bytes(b"fake") | |
| audio.clear_audio_cache() | |
| with mock.patch("soundfile.read", return_value=(fake_audio, 24000)) as mocked_read: | |
| audio.load_audio_file(str(audio_file)) | |
| audio.load_audio_file(str(audio_file)) | |
| assert mocked_read.call_count == 1 | |