Skip to content

Commit

Permalink
Merge pull request #1757 from langchain-ai/nc/18sep/unit-test-cancelled
Browse files Browse the repository at this point in the history
Add one more unit test for exception propagation
  • Loading branch information
nfcampos authored Sep 18, 2024
2 parents 94fa06e + 680fa3c commit f496247
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libs/langgraph/tests/test_pregel_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ async def iambad(input: Any) -> None:
assert inner_task_cancelled


async def test_node_cancellation_on_other_node_exception_two() -> None:
async def awhile(input: Any) -> None:
await asyncio.sleep(1)

async def iambad(input: Any) -> None:
raise ValueError("I am bad")

builder = Graph()
builder.add_node("agent", awhile)
builder.add_node("bad", iambad)
builder.set_conditional_entry_point(lambda _: ["agent", "bad"], then=END)

graph = builder.compile()

with pytest.raises(ValueError, match="I am bad"):
# This will raise ValueError, not CancelledError
await graph.ainvoke(1)


@pytest.mark.parametrize("checkpointer_name", ALL_CHECKPOINTERS_ASYNC)
async def test_dynamic_interrupt(checkpointer_name: str) -> None:
class State(TypedDict):
Expand Down

0 comments on commit f496247

Please sign in to comment.