mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-07 07:58:09 +00:00
The collected-loop tests ran a fixed 50 loops and passed with the fix reverted whenever no loop reused an earlier address. They now stop at the first reuse and skip if none happens, through a shared helper.
20 lines
690 B
Python
20 lines
690 B
Python
from collections.abc import Callable
|
|
from typing import Final, TypeVar
|
|
|
|
import pytest
|
|
|
|
LoopResult = TypeVar("LoopResult")
|
|
|
|
|
|
def runs_until_a_loop_address_repeats(
|
|
run_on_new_loop: Callable[[], tuple[int, LoopResult]],
|
|
earlier: tuple[tuple[int, LoopResult], ...] = (),
|
|
limit: int = 50,
|
|
) -> tuple[tuple[int, LoopResult], ...]:
|
|
if len(earlier) == limit:
|
|
pytest.skip(f"none of {limit} collected loops had its address handed to a later loop")
|
|
latest: Final = run_on_new_loop()
|
|
runs: Final = (*earlier, latest)
|
|
if latest[0] in {loop_id for loop_id, _ in earlier}:
|
|
return runs
|
|
return runs_until_a_loop_address_repeats(run_on_new_loop, runs, limit)
|