Skip to content

Commit

Permalink
fix locale name validation test to include -latn or -cyrl
Browse files Browse the repository at this point in the history
  • Loading branch information
krisfremen committed Oct 30, 2024
1 parent cdc225b commit b10b79b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ def test_locale_validation(self):
assert locale_cls.future is not None

def test_locale_name_validation(self):
import re
for locale_cls in self.locales.values():
for locale_name in locale_cls.names:
assert len(locale_name) == 2 or len(locale_name) == 5
assert locale_name.islower()
# Not a two-letter code
if len(locale_name) > 2:
assert "-" in locale_name
assert locale_name.count("-") == 1
pattern = r'^[a-z]{2}(-[a-z]{2})?(?:-latn|-cyrl)?$'
assert re.match(pattern, locale_name)

def test_duplicated_locale_name(self):
with pytest.raises(LookupError):
Expand Down

0 comments on commit b10b79b

Please sign in to comment.