Skip to content

Commit ab67038

Browse files
fix(tests): correct Cyrillic-A assertion to expect invalid-character warning
NFKC normalization does not map Cyrillic lookalikes to Latin characters (e.g. Cyrillic А U+0410 normalises to itself, not to Latin A U+0041). These characters are rejected correctly by the existing ASCII-only regex check, not by the new NFKC check. The test was asserting the wrong warning key; update it to assert the "invalid characters" diagnostic that is actually emitted, and add a comment explaining the distinction. Fixes review finding from cubic-dev-ai. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 1bbd671 commit ab67038

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tests/shared/test_tool_name_validation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,17 @@ class TestUnicodeHomoglyphDetection:
225225
"""Tests for detecting Unicode homoglyphs that visually impersonate ASCII."""
226226

227227
def test_cyrillic_a_rejected(self) -> None:
228-
"""Cyrillic А (U+0410) looks identical to Latin A but should be detected."""
228+
"""Cyrillic А (U+0410) looks identical to Latin A but must be rejected.
229+
230+
Note: NFKC does not map Cyrillic to Latin lookalikes, so this character
231+
is caught by the ASCII-only regex check (invalid characters), not by the
232+
normalization check. The rejection is the important invariant here.
233+
"""
229234
result = validate_tool_name("tool_А")
230235
assert not result.is_valid, "Cyrillic А should be rejected"
231236
assert any(
232-
"normalize" in w.lower() or "homoglyph" in w.lower()
233-
for w in result.warnings
234-
), f"Warning should mention normalization or homoglyph. Got: {result.warnings}"
237+
"invalid characters" in w.lower() for w in result.warnings
238+
), f"Expected invalid-character warning. Got: {result.warnings}"
235239

236240
def test_cyrillic_o_rejected(self) -> None:
237241
"""Cyrillic О (U+041E) looks identical to Latin O."""

0 commit comments

Comments
 (0)