Download tests/test_paths.py from hembad/reranker: direct link, hf CLI and curl.
- Browser
- Download file 900 Bytes
-
https://huggingface.co/spaces/hembad/reranker/resolve/main/tests/test_paths.py
- Command line
-
hf download hf://spaces/hembad/reranker/tests/test_paths.py
-
curl -L -o test_paths.py https://huggingface.co/spaces/hembad/reranker/resolve/main/tests/test_paths.py
900 Bytes
| """Repo-anchored path resolution — must work regardless of the process working directory.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| import pytest | |
| from common.paths import DEFAULT_CANDIDATES, REPO_ROOT, resolve_candidates | |
| def test_repo_root_points_at_the_repo() -> None: | |
| assert (REPO_ROOT / "data").is_dir() | |
| assert DEFAULT_CANDIDATES == REPO_ROOT / "data" / "candidates.jsonl" | |
| def test_resolves_relative_path_from_a_foreign_cwd(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: | |
| """Streamlit/HF launch from a non-repo cwd; a repo-relative path must still resolve.""" | |
| monkeypatch.chdir(tmp_path) | |
| resolved = resolve_candidates("data/candidate_schema.json") | |
| assert resolved.exists() | |
| def test_missing_path_is_returned_unchanged(tmp_path: Path) -> None: | |
| missing = tmp_path / "nope.jsonl" | |
| assert resolve_candidates(missing) == missing | |