litellm/tests
Yuneng Jiang 727ab8dcc4
[Fix] Proxy: Break managed-resources import cycle on Python 3.13
The Python 3.13 CCI smoke matrix surfaces a partially-initialized-module
ImportError when loading the managed files hook chain:

  litellm.proxy.hooks/__init__ (mid-import)
    -> enterprise.enterprise_hooks
    -> litellm_enterprise.proxy.hooks.managed_files
    -> litellm.llms.base_llm.managed_resources.isolation
    -> litellm.proxy.management_endpoints.common_utils
    -> litellm.proxy.utils  (re-enters litellm.proxy.hooks)

The except ImportError block in hooks/__init__.py silently swallowed the
failure, leaving managed_files unregistered and POST /files returning
500 "Managed files hook not found".

Two-layer fix:
- Inline the 3-line _user_has_admin_view check in isolation.py instead
  of importing it from litellm.proxy.management_endpoints.common_utils.
  litellm.llms.* should not depend on litellm.proxy.* — removing this
  layering violation breaks the cycle at its root.
- Define PROXY_HOOKS and get_proxy_hook before the conditional
  enterprise import in litellm/proxy/hooks/__init__.py, so any future
  re-entry resolves the public names instead of hitting an
  ImportError on a partially-initialized module.

Also fold in two unrelated CCI repairs surfaced in the same staging run:
- tests/otel_tests/test_key_logging_callbacks.py: per-key
  gcs_bucket_name / gcs_path_service_account are now stripped by
  initialize_dynamic_callback_params, so the GCS client falls through
  to the env-only branch. Update the assertion to match the new
  "GCS_BUCKET_NAME is not set" message.
- .circleci/config.yml: tests/pass_through_tests now resolves
  google-auth-library@10.x via the @google-cloud/vertexai 1.12.0 bump,
  which uses dynamic ESM imports Jest 29 cannot load without
  --experimental-vm-modules. Pass that flag in the Vertex JS test step.

Adds tests/test_litellm/proxy/hooks/test_proxy_hooks_init.py as a
regression guard: managed_files / managed_vector_stores must register,
and isolation.py must not transitively import litellm.proxy.utils.
2026-05-04 20:05:24 -07:00
..
agent_tests
audio_tests
basic_proxy_startup_tests
batches_tests Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_scim_virtual_key_deactivation 2026-05-01 20:29:19 -07:00
benchmarks
code_coverage_tests chore(deps): authorize pytest license 2026-05-04 11:39:46 -07:00
documentation_tests
enterprise fix metric labels for litellm-side rejects 2026-05-01 15:46:53 -07:00
guardrails_tests fix(guardrails): cover multi-choice output variants 2026-05-01 19:38:04 -07:00
image_gen_tests
litellm Merge remote-tracking branch 'origin/litellm_internal_staging' into codex/cloud-storage-file-guard 2026-05-04 11:25:41 -07:00
litellm_core_utils
litellm_utils_tests [Test] Anthropic: Replace Legacy Claude-4-Sonnet Alias With Haiku 4.5 2026-05-01 19:10:27 -07:00
litellm-proxy-extras
llm_responses_api_testing test(responses): replace legacy claude-4-sonnet alias in multiturn tool-call test 2026-05-03 07:48:56 +00:00
llm_translation Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_oss_staging_04_25_2026 2026-05-02 06:04:39 +00:00
load_tests
local_testing Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_/peaceful-bell-ba8ca5 2026-05-04 18:21:33 -07:00
logging_callback_tests fix(callbacks): preserve langfuse secret alias 2026-04-30 14:36:51 -07:00
mcp_tests
multi_instance_e2e_tests
ocr_tests
old_proxy_tests/tests
openai_endpoints_tests
otel_tests [Fix] Proxy: Break managed-resources import cycle on Python 3.13 2026-05-04 20:05:24 -07:00
pass_through_tests chore(deps): refresh dependency locks 2026-05-04 11:36:18 -07:00
pass_through_unit_tests fix: block path traversal SSRF in BitBucket, Arize Phoenix, and AssemblyAI clients (#26943) 2026-05-01 11:45:12 -07:00
proxy_admin_ui_tests chore(deps): refresh dependency locks 2026-05-04 11:36:18 -07:00
proxy_e2e_anthropic_messages_tests
proxy_security_tests
proxy_unit_tests Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix-ag-not-resolved 2026-05-01 17:21:29 -07:00
router_unit_tests fix(router): apply decoded provider for managed container IDs without model_id 2026-04-30 21:29:38 +00:00
scim_tests
search_tests
spend_tracking_tests chore(proxy): guard sensitive public endpoints 2026-04-30 11:52:47 -07:00
store_model_in_db_tests
test_litellm [Fix] Proxy: Break managed-resources import cycle on Python 3.13 2026-05-04 20:05:24 -07:00
unified_google_tests
vector_store_tests fix: drop milvus dbName and partitionNames from MILVUS_OPTIONAL_PARAMS 2026-04-30 11:51:32 -07:00
windows_tests
__init__.py
_flush_vcr_cache.py tests(vcr): isolate cassette redis to CASSETTE_REDIS_URL 2026-05-01 12:32:59 -07:00
_vcr_redis_persister.py fix(tests): anchor VCR redis cassette key to repo root 2026-05-01 23:27:18 +00:00
eval_swe_bench.py
gettysburg.wav
large_text.py
openai_batch_completions.jsonl
README.MD
test_budget_management.py
test_callbacks_on_proxy.py
test_config.py
test_debug_warning.py
test_default_encoding_non_root.py
test_end_users.py
test_entrypoint.py
test_fallbacks.py
test_gpt5_azure_temperature_support.py
test_health.py chore(proxy): preserve readiness compatibility 2026-04-30 12:05:09 -07:00
test_keys.py
test_litellm_proxy_responses_config.py
test_logging.conf
test_models.py
test_new_vector_store_endpoints.py
test_openai_endpoints.py
test_organizations.py
test_otel_thread_leak.py
test_passthrough_endpoints.py
test_presidio_latency.py
test_proxy_server_non_root.py
test_ratelimit.py
test_resource_cleanup.py
test_service_logger_otel.py
test_spend_logs.py
test_team_logging.py
test_team_members.py
test_team.py
test_users.py

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/test_litellm

This folder can only run mock tests.