Download tests/test_runtime.py from BurnyCoder/novel-tokens-reasoning-diffusion-llm: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/BurnyCoder/novel-tokens-reasoning-diffusion-llm/resolve/main/tests/test_runtime.py
- Command line
-
hf download hf://BurnyCoder/novel-tokens-reasoning-diffusion-llm/tests/test_runtime.py
-
curl -L -o test_runtime.py https://huggingface.co/BurnyCoder/novel-tokens-reasoning-diffusion-llm/resolve/main/tests/test_runtime.py
1.21 kB
| """Reproduce the Windows reader/writer collision observed on the live curves file.""" | |
| import json | |
| import pytest | |
| from novel_tokens import runtime | |
| def test_local_postponement_does_not_consume_a_milestone(tmp_path, monkeypatch): | |
| monkeypatch.setattr(runtime,"STORE",tmp_path) | |
| runtime.check_postponed() | |
| (tmp_path/"postpone.request").touch() | |
| with pytest.raises(runtime.CampaignPostponed): | |
| runtime.check_postponed() | |
| assert not list(tmp_path.glob("*milestones/*.json")) | |
| def test_atomic_writer_retries_sharing_violation(tmp_path, monkeypatch): | |
| dest = tmp_path / "curves.json" | |
| runtime.save_json(dest, {"step": 112}) | |
| replace = runtime.os.replace | |
| attempts = [] | |
| def held_once(source, target): | |
| attempts.append(target) | |
| if len(attempts) == 1: | |
| assert json.loads(dest.read_bytes()) == {"step": 112} | |
| error = PermissionError("test reader still holds the destination") | |
| error.winerror = 5 | |
| raise error | |
| replace(source, target) | |
| monkeypatch.setattr(runtime.os, "replace", held_once) | |
| runtime.save_json(dest, {"step": 113}) | |
| assert len(attempts) == 2 and json.loads(dest.read_bytes()) == {"step": 113} | |