def test_eq_with_cached_property():
    """
    Test BaseModel.__eq__ compatibility with functools.cached_property

    See GH-7444: https://github.com/pydantic/pydantic/issues/7444
    Previously, pydantic BaseModel.__eq__ compared the full __dict__ of
    model instances. This is not compatible with e.g. functools.cached_property,
    which caches the computed values in the instance's __dict__
    """

    class Model(BaseModel):
        attr: int

        @functools.cached_property
        def cached(self) -> int:
            return 0

    obj1 = Model(attr=1)
    obj2 = Model(attr=1)
    # ensure the instances are indeed equal before __dict__ mutations
    assert obj1 == obj2
    # This access to the cached_property has the side-effect of modifying obj1.__dict__
    # See functools.cached_property documentation and source code
    obj1.cached
    # Ensure the objects still compare equals after caching a property
    assert obj1 == obj2

    Test BaseModel.__eq__ compatibility with functools.cached_property

    See GH-7444: https://github.com/pydantic/pydantic/issues/7444
    Previously, pydantic BaseModel.__eq__ compared the full __dict__ of
    model instances. This is not compatible with e.g. functools.cached_property,
    which caches the computed values in the instance's __dict__
    
tests/test_edge_cases.py