def test_file_edit_observation_diff_cache():
    """Test that diff visualization is cached."""
    obs = FileEditObservation(
        path='/test/file.txt',
        prev_exist=True,
        old_content='Hello\nWorld\n',
        new_content='Hello\nNew World\n',
        impl_source=FileEditSource.LLM_BASED_EDIT,
        content='Hello\nWorld\n',  # Initial content is old_content
    )

    # First call should compute diff
    diff1 = obs.visualize_diff()
    assert obs._diff_cache is not None

    # Second call should use cache
    diff2 = obs.visualize_diff()
    assert diff1 == diff2
Test that diff visualization is cached.
tests/unit/test_file_edit_observation.py