1
0
Fork 0
mirror of https://github.com/qurator-spk/dinglehopper.git synced 2025-07-01 22:50:08 +02:00
dinglehopper/src/dinglehopper/tests/test_editops.py
Mike Gerber 325e5af5f5 🐛 Move source into src/ to fix install
Installing was broken since moving to pyproject.toml, which we didn't notice because of
leftover files in build/. Fix this by using the convention of having the source files
in src/ and adjusting pyproject.toml accordingly.

Fixes gh-86. 🤞
2023-08-03 17:29:30 +02:00

23 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) == []