mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
test: drop narrating comments and stacked generator clauses from cache_control tests
This commit is contained in:
parent
929a93ce38
commit
7ae26c5e02
4 changed files with 5 additions and 8 deletions
|
|
@ -9866,9 +9866,9 @@ def _five_cache_hint_conversation() -> list[dict[str, object]]:
|
|||
def _cached_texts(node: object) -> Iterator[str]:
|
||||
if isinstance(node, dict):
|
||||
yield from ((node["text"],) if "cache_control" in node and "text" in node else ())
|
||||
yield from (text for value in node.values() for text in _cached_texts(value))
|
||||
yield from chain.from_iterable(map(_cached_texts, node.values()))
|
||||
elif isinstance(node, list):
|
||||
yield from (text for item in node for text in _cached_texts(item))
|
||||
yield from chain.from_iterable(map(_cached_texts, node))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
|
|
@ -1891,9 +1891,7 @@ class TestCacheControlStrippingDoesNotMutateCallerInput:
|
|||
|
||||
request = self._transform(messages, tools)
|
||||
|
||||
# the outbound body must still be stripped, both message-level and nested
|
||||
assert "cache_control" not in json.dumps(request)
|
||||
# and the caller's objects must be untouched, nested content blocks included
|
||||
assert messages == messages_before
|
||||
assert tools == tools_before
|
||||
|
||||
|
|
|
|||
|
|
@ -582,9 +582,7 @@ class TestOpenAIResponsesAPIConfig:
|
|||
headers={},
|
||||
)
|
||||
|
||||
# the outbound body is still stripped
|
||||
assert "cache_control" not in json.dumps(result)
|
||||
# and the caller's objects are untouched, nested content blocks included
|
||||
assert input_with_cache_control == input_before
|
||||
assert tools_with_cache_control == tools_before
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import copy
|
||||
import json
|
||||
from collections.abc import Iterator
|
||||
from itertools import chain
|
||||
from typing import Final
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
|
@ -890,9 +891,9 @@ def _five_message_level_cache_hints() -> list[dict[str, object]]:
|
|||
def _cached_texts(node: object) -> Iterator[str]:
|
||||
if isinstance(node, dict):
|
||||
yield from ((node["text"],) if "cache_control" in node and "text" in node else ())
|
||||
yield from (text for value in node.values() for text in _cached_texts(value))
|
||||
yield from chain.from_iterable(map(_cached_texts, node.values()))
|
||||
elif isinstance(node, list):
|
||||
yield from (text for item in node for text in _cached_texts(item))
|
||||
yield from chain.from_iterable(map(_cached_texts, node))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue