Files
litellm/tests/local_testing
Mateo Wang 3f33efdd57 fix(tests): drop import-time completion call in test_register_model (#29521)
* fix(tests): drop import-time completion call in test_register_model

test_update_model_cost_via_completion() was invoked at module scope, so it
ran during pytest collection and fired a live OpenAI completion. The local
test jobs glob the whole tests/local_testing folder and let pytest import
every file, narrowing what runs only afterward with -k, so this call
executed in every one of those jobs regardless of their filter. When the
request failed (for instance a 429 once the OpenAI account hit its quota),
collection of the file errored and aborted the entire session, which is why
langfuse, assistants, router and local_testing_part2 all reported
"ERROR collecting tests/local_testing/test_register_model.py" and never ran
their own tests.

Remove the stray call and add a regression that parses the module and fails
if any locally defined function is invoked at module scope again

* test: also guard async def from module-scope invocation

ast.AsyncFunctionDef is a distinct node from ast.FunctionDef, so an async
test invoked at module scope would have slipped past the guard. Collect
both kinds of definitions

* fix(responses): send Content-Type application/json on OpenAI responses requests

OpenAI's responses API now rejects body-less requests (GET/DELETE) that
arrive without a content type, returning 500 "Unsupported content type:
'application/octet-stream'. This API method only accepts 'application/json'
requests". litellm's create path got the header for free because httpx sets
it when a json body is present, but the delete/get handlers send no body and
so sent no content type. The official OpenAI SDK declares
Content-Type: application/json on every request; mirror that in
validate_environment so all OpenAI responses calls carry it.

This is what made tests/openai_endpoints_tests/test_e2e_openai_responses_api.py::test_basic_response
fail on the responses.delete() call.
2026-06-02 16:10:43 -07:00
..
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 21:13:16 -07:00
2026-03-28 20:27:39 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-30 16:24:35 -07:00
2025-10-25 10:19:24 -07:00
2026-03-28 19:17:38 -07:00
2025-10-25 10:19:24 -07:00
2026-03-28 19:17:38 -07:00
2025-09-01 17:04:47 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2025-09-01 17:04:47 -07:00