Skip to content

Commit 0e91641

Browse files
committed
Test all locales, and skip when file not found
1 parent 863b132 commit 0e91641

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tests/test_i18n.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
import datetime as dt
66
import importlib
7+
import pathlib
78

89
import pytest
910
from freezegun import freeze_time
1011

1112
import humanize
1213

14+
LOCALE_DIR = pathlib.Path(humanize.i18n.__file__).parent / "locale"
15+
1316
with freeze_time("2020-02-02"):
1417
NOW = dt.datetime.now(tz=dt.timezone.utc)
1518

@@ -336,12 +339,15 @@ def test_none_locale(self) -> None:
336339
assert test_str == humanize.naturaltime(three_seconds)
337340

338341

339-
@pytest.mark.parametrize("locale", ["bn_BD", "ko_KR", "vi_VN"])
342+
@pytest.mark.parametrize(
343+
"locale", sorted(p.name for p in LOCALE_DIR.iterdir() if p.is_dir())
344+
)
340345
def test_intword_unit_has_no_format_placeholder(locale: str) -> None:
341-
"""`intword` interpolates the unit verbatim, so it must carry no placeholder."""
342346
try:
343347
humanize.i18n.activate(locale)
344348
for value in (1_000, 1_000_000, 1_000_000_000, 10**12, 10**15, 10**100):
345349
assert "%" not in humanize.intword(value)
350+
except FileNotFoundError:
351+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
346352
finally:
347353
humanize.i18n.deactivate()

0 commit comments

Comments
 (0)