Skip to content

Commit aee5511

Browse files
committed
✨ Add emoji mapping test
Signed-off-by: Paillat-dev <[email protected]>
1 parent 5f01a42 commit aee5511

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

discord/utils/public.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ def find(predicate: Callable[[T], Any], seq: Iterable[T]) -> T | None:
547547

548548
try:
549549
with importlib.resources.files(__package__).joinpath("../emojis.json").open(encoding="utf-8") as f: # pyright: ignore[reportArgumentType] # __package__ will always be discord.utils
550-
EMOJIS_MAP = json.load(f)
550+
EMOJIS_MAP: dict[str, str] = json.load(f)
551551
except FileNotFoundError:
552552
_log.debug(
553553
"Couldn't find emojis.json. Is the package data missing? Discord emojis names will not work.",
554554
)
555-
EMOJIS_MAP = {}
555+
EMOJIS_MAP = {} # pyright: ignore[reportConstantRedefinition]
556556
UNICODE_EMOJIS = set(EMOJIS_MAP.values())

tests/test_emojis_mapping.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021-present Pycord Development
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
25+
from discord.utils import UNICODE_EMOJIS
26+
27+
28+
def test_emoji_mapping_len():
29+
assert len(UNICODE_EMOJIS) > 0, "No unicode emojis loaded"

0 commit comments

Comments
 (0)