Skip to content

Commit b0d688c

Browse files
authored
Test non-ASCII digit rejection in Russian INNs
1 parent b748403 commit b0d688c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/i18n/test_ru.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,23 @@ def test_individual_inn_requires_both_check_digits(value: str):
6565
def test_individual_inn_check_digit_remainders(value: str):
6666
"""Accept both ordinary remainders and remainder 10 mapped to zero."""
6767
assert ru_inn(value) is True
68+
69+
70+
@pytest.mark.parametrize("value", ["7830002293", "500100732259"])
71+
@pytest.mark.parametrize("zero", ["\u0660", "\uff10", "\u0966"])
72+
def test_rejects_non_ascii_inn_digits(value: str, zero: str):
73+
"""Reject digit lookalikes in company and individual INNs."""
74+
translated = value.translate(
75+
str.maketrans("0123456789", "".join(chr(ord(zero) + n) for n in range(10)))
76+
)
77+
assert isinstance(ru_inn(translated), ValidationError)
78+
assert ru_inn(value) is True
79+
80+
81+
@pytest.mark.parametrize("value", ["7830002293", "500100732259"])
82+
@pytest.mark.parametrize("position", [0, -1])
83+
def test_rejects_mixed_ascii_and_non_ascii_inn_digits(value: str, position: int):
84+
"""A single non-ASCII digit must not be normalized by int()."""
85+
digits = list(value)
86+
digits[position] = chr(ord("\u0660") + int(digits[position]))
87+
assert isinstance(ru_inn("".join(digits)), ValidationError)

0 commit comments

Comments
 (0)