mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-06 21:20:33 +00:00
Add another test
This commit is contained in:
parent
da18e177f1
commit
6424b3cde0
@ -1,5 +1,5 @@
|
|||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -1282,3 +1282,17 @@ def test_each(snapshot: SnapshotAssertion) -> None:
|
|||||||
"test",
|
"test",
|
||||||
"this",
|
"this",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_recursive_lambda() -> None:
|
||||||
|
def _simple_recursion(x: int) -> Union[int, Runnable]:
|
||||||
|
if x < 10:
|
||||||
|
return RunnableLambda(lambda *args: _simple_recursion(x + 1))
|
||||||
|
else:
|
||||||
|
return x
|
||||||
|
|
||||||
|
runnable = RunnableLambda(_simple_recursion)
|
||||||
|
assert runnable.invoke(5) == 10
|
||||||
|
|
||||||
|
with pytest.raises(RecursionError):
|
||||||
|
runnable.invoke(0, {"recursion_limit": 9})
|
||||||
|
Loading…
Reference in New Issue
Block a user