Home / Function/ test_forwards_compat_model_dump_method() — anthropic-sdk-python Function Reference

test_forwards_compat_model_dump_method() — anthropic-sdk-python Function Reference

Architecture documentation for the test_forwards_compat_model_dump_method() function in test_models.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  00c20ec4_8a83_8918_813c_698e15b188b7["test_forwards_compat_model_dump_method()"]
  7872e60b_4210_5600_119f_c5d08c52091e["test_models.py"]
  00c20ec4_8a83_8918_813c_698e15b188b7 -->|defined in| 7872e60b_4210_5600_119f_c5d08c52091e
  style 00c20ec4_8a83_8918_813c_698e15b188b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_models.py lines 539–564

def test_forwards_compat_model_dump_method() -> None:
    class Model(BaseModel):
        foo: Optional[str] = Field(alias="FOO", default=None)

    m = Model(FOO="hello")
    assert m.model_dump() == {"foo": "hello"}
    assert m.model_dump(include={"bar"}) == {}
    assert m.model_dump(exclude={"foo"}) == {}
    assert m.model_dump(by_alias=True) == {"FOO": "hello"}

    m2 = Model()
    assert m2.model_dump() == {"foo": None}
    assert m2.model_dump(exclude_unset=True) == {}
    assert m2.model_dump(exclude_none=True) == {}
    assert m2.model_dump(exclude_defaults=True) == {}

    m3 = Model(FOO=None)
    assert m3.model_dump() == {"foo": None}
    assert m3.model_dump(exclude_none=True) == {}

    if PYDANTIC_V1:
        with pytest.raises(ValueError, match="round_trip is only supported in Pydantic v2"):
            m.model_dump(round_trip=True)

        with pytest.raises(ValueError, match="warnings is only supported in Pydantic v2"):
            m.model_dump(warnings=False)

Subdomains

Frequently Asked Questions

What does test_forwards_compat_model_dump_method() do?
test_forwards_compat_model_dump_method() is a function in the anthropic-sdk-python codebase, defined in tests/test_models.py.
Where is test_forwards_compat_model_dump_method() defined?
test_forwards_compat_model_dump_method() is defined in tests/test_models.py at line 539.

Analyze Your Own Codebase

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

Try Supermodel Free