Home / Function/ test_on_chain_error_updates_when_not_defers_inputs() — langchain Function Reference

test_on_chain_error_updates_when_not_defers_inputs() — langchain Function Reference

Architecture documentation for the test_on_chain_error_updates_when_not_defers_inputs() function in test_langchain.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  95f48af3_b182_678f_cc67_fa2fc42d963d["test_on_chain_error_updates_when_not_defers_inputs()"]
  6ee6ed10_3ff3_3d50_08bc_311ea99250db["test_langchain.py"]
  95f48af3_b182_678f_cc67_fa2fc42d963d -->|defined in| 6ee6ed10_3ff3_3d50_08bc_311ea99250db
  style 95f48af3_b182_678f_cc67_fa2fc42d963d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/tracers/test_langchain.py lines 535–570

def test_on_chain_error_updates_when_not_defers_inputs() -> None:
    """Tests `_on_chain_error` calls update (PATCH) when `defers_inputs` is not set."""
    client = unittest.mock.MagicMock(spec=Client)
    client.tracing_queue = None
    tracer = LangChainTracer(client=client)

    run_id = UUID("9d878ab3-e5ca-4218-aef6-44cbdc90160a")
    tracer.on_chain_start(
        {"name": "test_chain"},
        {"input": "hello"},
        run_id=run_id,
    )

    run = tracer.run_map[str(run_id)]
    run.error = "Test error"

    persist_called = False
    update_called = False

    def mock_persist(_: Any) -> None:
        nonlocal persist_called
        persist_called = True

    def mock_update(_: Any) -> None:
        nonlocal update_called
        update_called = True

    with (
        unittest.mock.patch.object(tracer, "_persist_run_single", mock_persist),
        unittest.mock.patch.object(tracer, "_update_run_single", mock_update),
    ):
        tracer._on_chain_error(run)

    # Should call update (PATCH), not persist (POST) for normal inputs
    assert not persist_called
    assert update_called

Domain

Subdomains

Frequently Asked Questions

What does test_on_chain_error_updates_when_not_defers_inputs() do?
test_on_chain_error_updates_when_not_defers_inputs() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/tracers/test_langchain.py.
Where is test_on_chain_error_updates_when_not_defers_inputs() defined?
test_on_chain_error_updates_when_not_defers_inputs() is defined in libs/core/tests/unit_tests/tracers/test_langchain.py at line 535.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free