From 3c0d9346c278f628ad1b340f4579eef63e08dda6 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 23 May 2025 13:51:13 -0700 Subject: [PATCH] Add sync test --- libs/langgraph/tests/test_pregel.py | 27 +++++++++++++++++++++++ libs/langgraph/tests/test_pregel_async.py | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index 5558daa68..1a6edb2bb 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -8769,3 +8769,30 @@ def test_get_graph_root_channel(snapshot: SnapshotAssertion) -> None: assert json.dumps(graph.get_graph().to_json(), indent=2) == snapshot assert graph.get_graph().draw_mermaid(with_styles=False) == snapshot + + +def test_imp_exception( + checkpointer: BaseCheckpointSaver, +) -> None: + @task() + def my_task(number: int): + time.sleep(0.1) + return number * 2 + + @task() + def task_with_exception(number: int): + time.sleep(0.1) + raise Exception("This is a test exception") + + @entrypoint(checkpointer=checkpointer) + def my_workflow(number: int): + my_task(number) + try: + task_with_exception(number) + except Exception as e: + print(f"Exception caught: {e}") + my_task(number) + return "done" + + thread1 = {"configurable": {"thread_id": "1"}} + assert my_workflow.invoke(1, thread1) == "done" diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 58745ec25..f77612241 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -9156,12 +9156,12 @@ async def test_imp_exception( ) -> None: @task() async def my_task(number: int): - await asyncio.sleep(1) + await asyncio.sleep(0.1) return number * 2 @task() async def task_with_exception(number: int): - await asyncio.sleep(1) + await asyncio.sleep(0.1) raise Exception("This is a test exception") @entrypoint(checkpointer=async_checkpointer)