Download tests/test_model_memory.py from turtle89431/Moxie-Multimedia: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/turtle89431/Moxie-Multimedia/resolve/main/tests/test_model_memory.py
- Command line
-
hf download hf://turtle89431/Moxie-Multimedia/tests/test_model_memory.py
-
curl -L -o test_model_memory.py https://huggingface.co/turtle89431/Moxie-Multimedia/resolve/main/tests/test_model_memory.py
866 Bytes
| from pathlib import Path | |
| import sys | |
| import types | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from utils import model_memory | |
| def test_cleanup_model_memory_skips_mps_cache_when_backend_is_unavailable(monkeypatch): | |
| calls = [] | |
| class FakeCuda: | |
| def is_available(): | |
| return False | |
| class FakeMpsBackend: | |
| def is_available(): | |
| return False | |
| class FakeBackends: | |
| mps = FakeMpsBackend() | |
| class FakeMps: | |
| def empty_cache(): | |
| calls.append("mps_empty_cache") | |
| fake_torch = types.SimpleNamespace( | |
| cuda=FakeCuda(), | |
| backends=FakeBackends(), | |
| mps=FakeMps(), | |
| ) | |
| monkeypatch.setitem(sys.modules, "torch", fake_torch) | |
| model_memory.cleanup_model_memory() | |
| assert calls == [] | |