From ed7facc1b108ceff12bcb412d7a98471509f41b0 Mon Sep 17 00:00:00 2001 From: cvzi Date: Wed, 2 Oct 2024 22:47:46 +0200 Subject: [PATCH] Fix test 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 --- tests/test_core.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 0bdbc6c..bc18b6d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -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 @@ -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)