Download gmnet/code/journal_exp/tests/test_code_fingerprint.py from YFanwang/Backup: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/datasets/YFanwang/Backup/resolve/main/gmnet/code/journal_exp/tests/test_code_fingerprint.py
- Command line
-
hf download hf://datasets/YFanwang/Backup/gmnet/code/journal_exp/tests/test_code_fingerprint.py
-
curl -L -o test_code_fingerprint.py https://huggingface.co/datasets/YFanwang/Backup/resolve/main/gmnet/code/journal_exp/tests/test_code_fingerprint.py
1.13 kB
| from pathlib import Path | |
| from scripts.code_fingerprint import build_manifest | |
| def test_code_manifest_is_root_independent_and_content_sensitive(tmp_path: Path) -> None: | |
| first = tmp_path / "first" | |
| second = tmp_path / "second" | |
| for root in (first, second): | |
| (root / "gmnet").mkdir(parents=True) | |
| (root / "scripts").mkdir() | |
| (root / "configs").mkdir() | |
| (root / "gmnet/model.py").write_text("VALUE = 1\n", encoding="utf-8") | |
| left = build_manifest(first) | |
| right = build_manifest(second) | |
| assert left == right | |
| (second / "gmnet/model.py").write_text("VALUE = 2\n", encoding="utf-8") | |
| changed = build_manifest(second) | |
| assert changed["code_sha256"] != left["code_sha256"] | |
| def test_code_manifest_uses_relative_sorted_paths(tmp_path: Path) -> None: | |
| (tmp_path / "gmnet/z").mkdir(parents=True) | |
| (tmp_path / "gmnet/z/b.py").write_text("b\n", encoding="utf-8") | |
| (tmp_path / "gmnet/a.py").write_text("a\n", encoding="utf-8") | |
| records = build_manifest(tmp_path)["files"] | |
| paths = [record["path"] for record in records] | |
| assert paths == ["gmnet/a.py", "gmnet/z/b.py"] | |