def test_mutable_models():
    """Test that dataclass and pydantic BaseModel v1 and v2 use dep tracking."""
    state = PydanticState()
    assert isinstance(state.v1, MutableProxy)
    state.v1.foo = "baz"
    assert state.dirty_vars == {"v1"}
    state.dirty_vars.clear()

    assert isinstance(state.v2, MutableProxy)
    state.v2.foo = "baz"
    assert state.dirty_vars == {"v2"}
    state.dirty_vars.clear()

    assert isinstance(state.dc, MutableProxy)
    state.dc.foo = "baz"
    assert state.dirty_vars == {"dc"}
    state.dirty_vars.clear()
    assert state.dirty_vars == set()
    state.dc.ls.append({"hi": "reflex"})
    assert state.dirty_vars == {"dc"}
    state.dirty_vars.clear()
    assert state.dirty_vars == set()
    assert dataclasses.asdict(state.dc) == {"foo": "baz", "ls": [{"hi": "reflex"}]}
    assert dataclasses.astuple(state.dc) == ("baz", [{"hi": "reflex"}])
    # creating a new instance shouldn't mark the state dirty
    assert dataclasses.replace(state.dc, foo="quuc") == ModelDC(
        foo="quuc", ls=[{"hi": "reflex"}]
    )
    assert state.dirty_vars == set()
Test that dataclass and pydantic BaseModel v1 and v2 use dep tracking.
tests/units/test_state.py