You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dinglehopper/dinglehopper/tests/test_editops.py

24 lines
856 B
Python

import unicodedata
from .. import editops
def test_editops():
"""Test editops() in cases where dealing with grapheme clusters matters"""
# In these cases, one of the words has a composed form, the other one does not.
# (Also, note that old terminal emulators might not render the combining characters
# correctly, be sure to read in an editor.)
assert editops("Schlyñ", "Schlym̃") == [("replace", 5, 5)]
assert editops("oͤde", "öde") == [("replace", 0, 0)]
def test_editops_canonically_equivalent():
left = unicodedata.lookup("LATIN SMALL LETTER N") + unicodedata.lookup(
"COMBINING TILDE"
)
right = unicodedata.lookup("LATIN SMALL LETTER N WITH TILDE")
assert left != right
assert unicodedata.normalize("NFC", left) == unicodedata.normalize("NFC", right)
assert editops(left, right) == []