Home / Function/ test_create_model_v2() — langchain Function Reference

test_create_model_v2() — langchain Function Reference

Architecture documentation for the test_create_model_v2() function in test_pydantic.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  d332d7df_b418_7c30_0974_e98d6901401f["test_create_model_v2()"]
  f94b56e0_336c_6748_3628_73edd4212b01["test_pydantic.py"]
  d332d7df_b418_7c30_0974_e98d6901401f -->|defined in| f94b56e0_336c_6748_3628_73edd4212b01
  style d332d7df_b418_7c30_0974_e98d6901401f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_pydantic.py lines 156–188

def test_create_model_v2() -> None:
    """Test that create model v2 works as expected."""
    with warnings.catch_warnings(record=True) as record:
        warnings.simplefilter("always")  # Cause all warnings to always be triggered
        foo = create_model_v2("Foo", field_definitions={"a": (int, None)})
        foo.model_json_schema()

    assert list(record) == []

    # schema is used by pydantic, but OK to re-use
    with warnings.catch_warnings(record=True) as record:
        warnings.simplefilter("always")  # Cause all warnings to always be triggered
        foo = create_model_v2("Foo", field_definitions={"schema": (int, None)})
        foo.model_json_schema()

    assert list(record) == []

    # From protected namespaces, but definitely OK to use.
    with warnings.catch_warnings(record=True) as record:
        warnings.simplefilter("always")  # Cause all warnings to always be triggered
        foo = create_model_v2("Foo", field_definitions={"model_id": (int, None)})
        foo.model_json_schema()

    assert list(record) == []

    with warnings.catch_warnings(record=True) as record:
        warnings.simplefilter("always")  # Cause all warnings to always be triggered
        # Verify that we can use non-English characters
        field_name = "もしもし"
        foo = create_model_v2("Foo", field_definitions={field_name: (int, None)})
        foo.model_json_schema()

    assert list(record) == []

Domain

Subdomains

Frequently Asked Questions

What does test_create_model_v2() do?
test_create_model_v2() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_pydantic.py.
Where is test_create_model_v2() defined?
test_create_model_v2() is defined in libs/core/tests/unit_tests/utils/test_pydantic.py at line 156.

Analyze Your Own Codebase

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

Try Supermodel Free