litellm/tests/unit/google_genai
joshua-berri e4759def40
fix(logging): retain streaming success logging tasks until they finish (#52067)
* fix(logging): retain streaming success logging tasks until they finish

Streaming chat, A2A, Gemini/Vertex and the proxy's deferred chat stream
logging scheduled their success dispatch with a bare asyncio.create_task.
The loop only holds weak references to tasks, so a dispatch suspended on
an awaitable nothing else reaches could be garbage collected mid-flight
and its spend log never written. Route them through spawn_logging_task,
which keeps a strong reference until completion, logs failures and is
drained at proxy shutdown.

* test(logging): release parked logging callbacks on every exit path

Wrap the garbage collection regressions in a context manager that releases
the parked callback, waits for its task and drains the logging registry even
when the test fails, assert exactly one parked callback, and leave the
orphaned closure dispatch on its original schedule.

* test(logging): cancel a parked logging callback that never finishes

Cancel and await the parked task if it is still pending after release, fail
the test in that case, and leave the streaming cache write on its original
schedule since it hands off to an already tracked write without suspending.

---------

Co-authored-by: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com>
2026-11-16 11:21:05 -08:00
..
__init__.py test: move tests/test_litellm root and small trees into tests/unit (#43186) 2026-09-25 11:30:43 -07:00
test_google_genai_adapter.py fix(google_genai): read one-object and null spellings of repeated fields in countTokens and generateContent (#48771) 2026-10-28 21:46:06 -07:00
test_google_genai_adapter_fixes.py test: move tests/test_litellm root and small trees into tests/unit (#43186) 2026-09-25 11:30:43 -07:00
test_google_genai_handler.py fix(vertex_ai): route Model Garden models through the generateContent adapter (#41836) 2026-10-15 08:06:49 -07:00
test_google_genai_main.py feat(custom_llm): let custom providers serve native generateContent (#51083) 2026-11-14 05:57:58 -05:00
test_google_genai_streaming_iterator.py fix(logging): retain streaming success logging tasks until they finish (#52067) 2026-11-16 11:21:05 -08:00
test_google_genai_transformation.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00