Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed implementation error of emoji.distinct_emoji_lis #156

Merged
merged 3 commits into from Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions emoji/core.py
Expand Up @@ -137,10 +137,10 @@ def emoji_lis(string, language='en'):
return _entities


def distinct_emoji_lis(string):
def distinct_emoji_lis(string, language='en'):
"""Returns distinct list of emojis from the string."""
distinct_list = list(
{c for c in string if c in unicode_codes.UNICODE_EMOJI}
{e['emoji'] for e in emoji_lis(string, language)}
)
return distinct_list

Expand Down
7 changes: 7 additions & 0 deletions tests/test_core.py
Expand Up @@ -72,6 +72,13 @@ def test_emoji_lis():
assert emoji.emoji_lis('Hello 🇫🇷👌') == [{'emoji': '🇫🇷', 'location': 6}, {'emoji': '👌', 'location': 8}]


def test_distinct_emoji_lis():
assert emoji.distinct_emoji_lis('Hi, I am fine. 😁') == ['😁']
assert emoji.distinct_emoji_lis('Hi') == []
assert set(emoji.distinct_emoji_lis('Hello 🇫🇷👌')) == {'🇫🇷', '👌'}
assert emoji.distinct_emoji_lis('Hi, I am fine. 😁😁😁😁') == ['😁']


def test_emoji_count():
assert emoji.emoji_count('Hi, I am fine. 😁') == 1
assert emoji.emoji_count('Hi') == 0
Expand Down