Skip to content

Commit

Permalink
TST: Add translation test for naturaldelta
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Jun 22, 2022
1 parent 6c1d0c7 commit cfdfb81
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ def test_intcomma() -> None:
humanize.i18n.deactivate()
assert humanize.intcomma(number) == "10,000,000"

def test_naturaldelta() -> None:
seconds = 1234 * 365 * 24 * 60 * 60

assert humanize.naturaldelta(seconds) == "1,234 years"

try:
humanize.i18n.activate("fr_FR")
assert humanize.naturaldelta(seconds) == "1 234 ans"
humanize.i18n.activate("es_ES")
assert humanize.naturaldelta(seconds) == "1,234 años"

except FileNotFoundError:
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")

finally:
humanize.i18n.deactivate()
assert humanize.naturaldelta(seconds) == "1,234 years"

@pytest.mark.parametrize(
("locale", "number", "expected_result"),
Expand Down

0 comments on commit cfdfb81

Please sign in to comment.