4 Commits

4 changed files with 33 additions and 2 deletions

View File

@@ -120,6 +120,7 @@ exclude = [
"src/dismoji/_version.py"
]
[tool.ruff.lint]
select = ["ALL"]
per-file-ignores = { "examples/**/*" = ["INP001", "ARG002", "T201"], "tests/**/*" = ["S101"], "src/dismoji/_version.py" = ["I001", "Q000", "UP005", "UP006", "UP035"] }
@@ -151,6 +152,7 @@ extend-ignore = [
"C901",
"ISC003" # conflicts with basedpyright reportImplicitStringConcatenation
]
pydocstyle.convention = "google"
[tool.uv.sources]
py-cord = { git = "https://github.com/Pycord-Development/pycord", rev = "c0c0b7c58f7b489983a159f5e0eea2c0dab0b0c8" }

View File

@@ -14,7 +14,9 @@ with EMOJIS_PATH.open("r", encoding="utf-8") as f:
EMOJI_MAPPING: dict[str, str] = {k: EMOJIS["emojis"][v]["surrogates"] for k, v in EMOJIS["nameToEmoji"].items()}
EMOJI_PATTERN = re.compile(r"(?<!\w):([a-zA-Z0-9_-]+):(?!\w)")
del EMOJIS # Clean up to save memory
EMOJI_PATTERN = re.compile(r":([a-zA-Z0-9_-]+):")
def emojize(s: str) -> str:

View File

@@ -41,3 +41,30 @@ def test_multiple_emojis() -> None:
def test_complex_sentence() -> None:
"""Test emojize function with a complex sentence."""
assert emojize("Hello :wave:, what's up? :smile: :white_check_mark: :smile:") == "Hello 👋, what's up? 😄 ✅ 😄"
def test_spaces() -> None:
"""Test emojize function with spaces."""
space_tests = [
("Hello :smile::smile:", "Hello 😄😄"),
("Hii what's up :wave:?", "Hii what's up 👋?"),
("Hello:wave: :smile:", "Hello👋 😄"),
("Hellooo :wave:hru?", "Hellooo 👋hru?"),
("Hii:wave:hru?", "Hii👋hru?"),
]
for input_str, expected_output in space_tests:
assert emojize(input_str) == expected_output
def test_emoji_with_special_characters() -> None:
"""Test emojize function with special characters."""
special_char_tests = [
("Hello :smile:!", "Hello 😄!"),
("Hello :smile:?", "Hello 😄?"),
("Hello :smile::smile:!", "Hello 😄😄!"),
("Hello :smile::smile:?", "Hello 😄😄?"),
("Hello :smile::smile::smile:!", "Hello 😄😄😄!"),
("Hello :smile::smile::smile:?", "Hello 😄😄😄?"),
]
for input_str, expected_output in special_char_tests:
assert emojize(input_str) == expected_output