mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(tests): replace asyncio.sleep(1) with event-based wait in metadata callback tests
This commit is contained in:
parent
c6ae2eccac
commit
d2b7843d4b
1 changed files with 4 additions and 2 deletions
|
|
@ -44,11 +44,13 @@ class MetadataCaptureCallback(CustomLogger):
|
|||
|
||||
def __init__(self):
|
||||
self.captured_kwargs: Optional[dict] = None
|
||||
self.event = asyncio.Event()
|
||||
|
||||
async def async_log_success_event(
|
||||
self, kwargs, response_obj, start_time, end_time
|
||||
):
|
||||
self.captured_kwargs = kwargs
|
||||
self.event.set()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -104,7 +106,7 @@ async def test_metadata_passed_to_custom_callback_codex_models():
|
|||
metadata=test_metadata,
|
||||
)
|
||||
|
||||
await asyncio.sleep(1)
|
||||
await asyncio.wait_for(callback.event.wait(), timeout=5.0)
|
||||
|
||||
assert callback.captured_kwargs is not None, "Callback should have been invoked"
|
||||
|
||||
|
|
@ -165,7 +167,7 @@ async def test_metadata_passed_via_litellm_metadata_responses_api():
|
|||
litellm_metadata=test_metadata,
|
||||
)
|
||||
|
||||
await asyncio.sleep(1)
|
||||
await asyncio.wait_for(callback.event.wait(), timeout=5.0)
|
||||
|
||||
assert callback.captured_kwargs is not None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue