Files
litellm/tests/test_litellm
Julio Quinteros Pro 5f79bf4906 fix(test): clear tokenizer LRU cache for test isolation
The _select_tokenizer_helper function is decorated with @lru_cache, which
causes test failures when tests run sequentially with --dist=loadscope.
Previous tests' cached results prevent from_pretrained from being called,
causing mock assertions to fail.

Implemented triple-layer cache clearing:
1. Module-level clear on import
2. Class-level clear in setUpClass
3. Function-level clear in setUp + pytest fixture

This ensures test isolation while allowing --dist=loadscope to provide better
overall CI stability (70% pass rate vs 40% without loadscope).

Fixes the intermittent failure in TestTokenizerSelection where
'from_pretrained' mock was never called due to cache hits.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 20:23:27 -03:00
..
2026-01-24 11:13:44 -08:00
2026-02-14 13:40:48 -08:00

Testing for litellm/

This directory 1:1 maps the the litellm/ directory, and can only contain mocked tests.

The point of this is to:

  1. Increase test coverage of litellm/
  2. Make it easy for contributors to add tests for the litellm/ package and easily run tests without needing LLM API keys.

File name conventions

  • litellm/proxy/test_caching_routes.py maps to litellm/proxy/caching_routes.py
  • test_<filename>.py maps to litellm/<filename>.py