from bindery.diffing import diff_html, html_to_blocks, text_hash def test_random_class_names_do_not_count_as_changes(): a = '

Hello there.

Second

' b = '

Hello there.

Second

' assert text_hash(a) == text_hash(b) assert html_to_blocks(a) == ["Hello there.", "Second"] def test_text_changes_change_the_hash(): assert text_hash("

one

") != text_hash("

two

") def test_diff_counts_and_word_level_changes(): old = "

Same.

The cat sat.

Gone.

" new = "

Same.

The dog sat.

Gone.

Added.

" result = diff_html(old, new) assert (result["changed"], result["added"], result["removed"]) == (1, 1, 0) assert "catdog" in result["html"] assert not result["identical"] def test_diff_output_is_escaped(): result = diff_html("

a

", "

<script>alert(1)</script>

") assert "