Skip to content

Commit

Permalink
Merge pull request #293 from cvzi/fix-test_non_rgi_zwj_replace
Browse files Browse the repository at this point in the history
Fix tests relying on a fixed execution order
  • Loading branch information
TahirJalilov committed May 15, 2024
2 parents a1332a6 + 720eb8d commit fd4230c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ def test_untranslated():


def test_text():
emoji.config.demojize_keep_zwj = True # Restore default config value
emoji.config.replace_emoji_keep_zwj = False # Restore default config value

UCS2 = len('Hello 🇫🇷👌') > 9 # don't break up characters on python with UCS-2

text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_zwj_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def test_malformed_zwj_no_emoji():


def test_malformed_zwj_mixed_with_emoji():
emoji.config.demojize_keep_zwj = True # Restore default config value

i = "Has🦷\u200Din the middle"
o = "Has:tooth:\u200Din the middle"
assert emoji.demojize(i) == o, f"{i!r} != {o!r}"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_zwj_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ def test_non_rgi_zwj_replace():
assert emoji.replace_emoji('\U0001F468\U0001F3FF\u200d\U0001F469\u200d\U0001F467\U0001F3FB\u200d\U0001F466', 'X') == 'XXXX'

# https://www.unicode.org/Public/15.0.0/ucd/auxiliary/GraphemeBreakTest-15.0.0d1.html#s19
assert emoji.demojize('\U0001f3ff\U0001f476\u200d\U0001f6d1') == ':dark_skin_tone::baby::stop_sign:'
assert emoji.replace_emoji('\U0001f3ff\U0001f476\u200d\U0001f6d1', 'Test8') == 'Test8Test8Test8'

# https://www.unicode.org/Public/15.0.0/ucd/auxiliary/GraphemeBreakTest-15.0.0d1.html#s20
# Check that \u200d is kept, if it not part of a valid ZWJ emoji
assert emoji.demojize('\U0001f476\U0001f3ff\u0308\u200d\U0001f476\U0001f3ff') == ':baby_dark_skin_tone:\u0308\u200d:baby_dark_skin_tone:'
assert emoji.replace_emoji('\U0001f476\U0001f3ff\u0308\u200d\U0001f476\U0001f3ff', 'Test9') == 'Test9\u0308\u200dTest9'

# Replace with different length
index = [0]
Expand Down

0 comments on commit fd4230c

Please sign in to comment.