Update tests/test_utils_pvpreload.py
Run CI Tests / test (push) Successful in 1m7s

This commit is contained in:
2025-08-07 22:18:53 +02:00
parent f138f0035a
commit c100b138f5
+20
View File
@@ -142,6 +142,26 @@ def test_preload_old_file(tmp_path, caplog):
# Vérifie que le PV na pas été créé (pas dans le cache)
assert not is_pv_in_cache(pvname)
def test_preload_fichier_corrompu(tmp_path, caplog):
configure_logzero_for_pytest(caplog)
f = tmp_path / "corrupt.pkl"
# Écrit un fichier non valide (pas du pickle)
with open(f, "w") as fcorrupt:
fcorrupt.write("not a pickle at all")
# Patch le chemin du fichier dans preload
with pytest.MonkeyPatch().context() as mp:
mp.setattr("slic.utils.pvpreload.fn", f)
with caplog.at_level("WARNING"):
preload()
logs = "\n".join(caplog.messages)
assert "PV preload file not loaded due to: UnpicklingError:" in logs
# offload()
def test_offload(tmp_path, caplog):