test_ensure_config() — langchain Function Reference
Architecture documentation for the test_ensure_config() function in test_config.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 027ec394_0bff_96a4_59bc_ca75eff5c42e["test_ensure_config()"] 8b969f31_85c5_bfa6_c6dd_4c29568f829f["test_config.py"] 027ec394_0bff_96a4_59bc_ca75eff5c42e -->|defined in| 8b969f31_85c5_bfa6_c6dd_4c29568f829f style 027ec394_0bff_96a4_59bc_ca75eff5c42e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_config.py lines 27–71
def test_ensure_config() -> None:
run_id = str(uuid.uuid4())
arg: dict[str, Any] = {
"something": "else",
"metadata": {"foo": "bar"},
"configurable": {"baz": "qux"},
"callbacks": [StdOutCallbackHandler()],
"tags": ["tag1", "tag2"],
"max_concurrency": 1,
"recursion_limit": 100,
"run_id": run_id,
"run_name": "test",
}
arg_str = json.dumps({**arg, "callbacks": []})
ctx = copy_context()
ctx.run(
_set_config_context,
{
"callbacks": [ConsoleCallbackHandler()],
"metadata": {"a": "b"},
"configurable": {"c": "d"},
"tags": ["tag3", "tag4"],
},
)
config = ctx.run(ensure_config, cast("RunnableConfig", arg))
assert len(arg["callbacks"]) == 1, (
"ensure_config should not modify the original config"
)
assert json.dumps({**arg, "callbacks": []}) == arg_str, (
"ensure_config should not modify the original config"
)
assert config is not arg
assert config["callbacks"] is not arg["callbacks"]
assert config["metadata"] is not arg["metadata"]
assert config["configurable"] is not arg["configurable"]
assert config == {
"tags": ["tag1", "tag2"],
"metadata": {"foo": "bar", "baz": "qux", "something": "else"},
"callbacks": [arg["callbacks"][0]],
"recursion_limit": 100,
"configurable": {"baz": "qux", "something": "else"},
"max_concurrency": 1,
"run_id": run_id,
"run_name": "test",
}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_ensure_config() do?
test_ensure_config() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_config.py.
Where is test_ensure_config() defined?
test_ensure_config() is defined in libs/core/tests/unit_tests/runnables/test_config.py at line 27.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free