mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-11 09:05:16 +00:00
4b3f5d7f81
Addresses review feedback on the snapshot approach: 1. Class-instance mutable state The snapshot only covers primitives + collections + None. Class instances (DualCache, LLMClientCache) weren't reset between tests, so in-place cache mutations could leak. Can't deepcopy these — they hold thread locks — but they expose flush_cache(). Collect every module attribute whose value implements flush_cache() at conftest import, and invoke it per-test alongside the snapshot restore. 2. Silent skips are now warnings _snapshot_mutable_state and _restore_mutable_state previously swallowed exceptions, so if a future attr gained a property without a setter (or other non-round-trippable state), an isolation gap would have no signal. Emit warnings.warn on each failure path. 3. Docstring Explicitly documents what IS and IS NOT reset, and tells authors to use monkeypatch.setattr() for in-place mutations of instances without flush_cache() (ProxyLogging, JWTHandler, etc.).