Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /HKUDS_LightRAG /tests /utils /test_load_json.py
| """load_json: empty store files must match the missing-file contract.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| import pytest | |
| from lightrag.utils import load_json | |
| pytestmark = pytest.mark.offline | |
| def test_missing_file_returns_none(tmp_path: Path) -> None: | |
| assert load_json(str(tmp_path / "no-such.json")) is None | |
| def test_empty_or_whitespace_file_returns_none(tmp_path: Path, payload: bytes) -> None: | |
| path = tmp_path / "kv.json" | |
| path.write_bytes(payload) | |
| assert load_json(str(path)) is None | |
| assert (load_json(str(path)) or {}) == {} | |
| def test_invalid_json_still_raises(tmp_path: Path) -> None: | |
| path = tmp_path / "kv.json" | |
| path.write_text("{not json", encoding="utf-8") | |
| with pytest.raises(json.JSONDecodeError): | |
| load_json(str(path)) | |
| def test_valid_json_still_loads(tmp_path: Path) -> None: | |
| path = tmp_path / "kv.json" | |
| path.write_text('{"a": 1}', encoding="utf-8") | |
| assert load_json(str(path)) == {"a": 1} | |
| def test_empty_object_json_is_not_none(tmp_path: Path) -> None: | |
| path = tmp_path / "kv.json" | |
| path.write_text("{}", encoding="utf-8") | |
| assert load_json(str(path)) == {} | |
Xet Storage Details
- Size:
- 1.24 kB
- Xet hash:
- 81e6805a41cd5887dc45defff34174ed30b7115428e0834cae70583cac3386d8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.