Spaces:
Runtime error
Runtime error
Arthur_Diaz
feat(reading): add cloze (fill-in-the-blank) as a second exercise type (#5)
8a8cb44 unverified Download tests/test_cache.py from blizzarman/polyglot-tutor: direct link, hf CLI and curl.
- Browser
- Download file 844 Bytes
-
https://huggingface.co/spaces/blizzarman/polyglot-tutor/resolve/main/tests/test_cache.py
- Command line
-
hf download hf://spaces/blizzarman/polyglot-tutor/tests/test_cache.py
-
curl -L -o test_cache.py https://huggingface.co/spaces/blizzarman/polyglot-tutor/resolve/main/tests/test_cache.py
844 Bytes
| from tutor.services.cache import FileCache | |
| def test_key_is_stable_and_separator_safe() -> None: | |
| assert FileCache.key("a", "b") == FileCache.key("a", "b") | |
| assert FileCache.key("a", "b") != FileCache.key("ab") | |
| assert FileCache.key("a", "b") != FileCache.key("a:b") | |
| def test_roundtrip_and_miss(tmp_path) -> None: | |
| cache = FileCache(tmp_path / "nested" / "dir") # created on init | |
| key = FileCache.key("text", "1", "model", "B1", "the ocean") | |
| assert cache.get(key) is None | |
| cache.set(key, {"text": "héllo", "attempts": 2}) | |
| assert cache.get(key) == {"text": "héllo", "attempts": 2} | |
| def test_corrupt_entry_behaves_like_a_miss(tmp_path) -> None: | |
| cache = FileCache(tmp_path) | |
| key = FileCache.key("x") | |
| (tmp_path / f"{key}.json").write_text("{not json", encoding="utf-8") | |
| assert cache.get(key) is None | |