mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
Since #35491, register_model records every registration in the process-global _runtime_registered_model_cost ledger, and every cost map swap replays that ledger on top of the freshly adopted map. Under pytest-xdist, any earlier test in the same worker that registered gpt-3.5-turbo leaked into TestPriceDataReloadIntegration::test_distributed_reload_check_function: the replay ballooned its sparse mocked entry into a full ModelInfo dict and failed the exact-equality assert, breaking the proxy-infra shard whenever loadscope happened to co-schedule such a test first (reruns cannot help since the pollution is process-wide) The autouse isolate_litellm_state fixture now snapshots the ledger before each test and restores it in place on teardown, so no test's registrations outlive it. A regression pair in test_conftest_isolation.py asserts the rollback
13 lines
506 B
Python
13 lines
506 B
Python
import litellm
|
|
from litellm import utils as litellm_utils_module
|
|
|
|
CANARY_MODEL = "conftest-isolation-canary-model"
|
|
|
|
|
|
def test_register_model_ledger_entry_is_scoped_to_this_test():
|
|
litellm.register_model({CANARY_MODEL: {"litellm_provider": "openai", "input_cost_per_token": 0.001}})
|
|
assert CANARY_MODEL in litellm_utils_module._runtime_registered_model_cost
|
|
|
|
|
|
def test_register_model_ledger_entry_was_rolled_back():
|
|
assert CANARY_MODEL not in litellm_utils_module._runtime_registered_model_cost
|