Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Cannot use "component"-emoji in the test, because a component that follows an emoji can create an ambiguous result:
`:right-facing_fist::dark_skin_tone:` and `:right-facing_fist_dark_skin_tone:` evaluate to the same emoji
  • Loading branch information
cvzi committed Oct 2, 2024
1 parent 960ebe7 commit ed7facc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,18 @@ def add_random_emoji(
def clean(s: str) -> str:
return s.replace('\u200d', '').replace('\ufe0f', '')

all_emoji_list = list(emoji.EMOJI_DATA.items())
qualified_emoji_list = [
(emj, item)
for emj, item in emoji.EMOJI_DATA.items()
if item['status'] == emoji.STATUS['fully_qualified']
]

all_emoji_list_except_component = [
(emj, item)
for emj, item in emoji.EMOJI_DATA.items()
if item['status'] >= emoji.STATUS['fully_qualified']
]

# qualified emoji
text_with_unicode, text_with_placeholder, emoji_list = add_random_emoji(
text, qualified_emoji_list
Expand Down Expand Up @@ -644,9 +649,9 @@ def select_alias(emj_data: Dict[str, Any]) -> Union[str, Literal[False]]:
for i, lis in enumerate(emoji.emoji_list(text_with_unicode)):
assert lis['emoji'] == emoji_list[i]

# all emoji
# all emoji (except components)
text_with_unicode, text_with_placeholder, emoji_list = add_random_emoji(
text, all_emoji_list
text, all_emoji_list_except_component
)
assert emoji.demojize(text_with_unicode) == text_with_placeholder
assert clean(emoji.emojize(text_with_placeholder)) == clean(text_with_unicode)
Expand Down

0 comments on commit ed7facc

Please sign in to comment.