mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
Tighten usage assertion: check usage is not None instead of hasattr
This commit is contained in:
parent
65918b0495
commit
e220b5ad35
1 changed files with 6 additions and 2 deletions
|
|
@ -2173,7 +2173,9 @@ class TestUsageChunkEmptyChoices:
|
|||
|
||||
# The last chunk should be the usage chunk
|
||||
usage_chunk = collected[-1]
|
||||
assert hasattr(usage_chunk, "usage"), "Final chunk should carry usage"
|
||||
assert (
|
||||
getattr(usage_chunk, "usage", None) is not None
|
||||
), "Final chunk should carry non-None usage"
|
||||
assert usage_chunk.choices == [], (
|
||||
f"Usage chunk must have choices=[] per OpenAI spec, "
|
||||
f"got {usage_chunk.choices!r}"
|
||||
|
|
@ -2189,7 +2191,9 @@ class TestUsageChunkEmptyChoices:
|
|||
collected.append(chunk)
|
||||
|
||||
usage_chunk = collected[-1]
|
||||
assert hasattr(usage_chunk, "usage"), "Final chunk should carry usage"
|
||||
assert (
|
||||
getattr(usage_chunk, "usage", None) is not None
|
||||
), "Final chunk should carry non-None usage"
|
||||
assert usage_chunk.choices == [], (
|
||||
f"Usage chunk must have choices=[] per OpenAI spec, "
|
||||
f"got {usage_chunk.choices!r}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue