Skip to content

Commit

Permalink
Add smoke test for all RBNF-enabled locales and rulesets
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 28, 2022
1 parent e9390df commit 9731112
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ norecursedirs = venv* .* _* scripts {args}
doctest_optionflags = ELLIPSIS NORMALIZE_WHITESPACE ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL
markers =
all_locales: parameterize test with all locales
all_rbnf_locales: parameterize test with all locales with RBNF rules

[bdist_wheel]
universal = 1
Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ def pytest_generate_tests(metafunc):
from babel.localedata import locale_identifiers
metafunc.parametrize("locale", list(locale_identifiers()))
break
if mark.name == "all_rbnf_locales":
from babel.core import get_global
metafunc.parametrize("locale", list(get_global('rbnf_locales')))
break
9 changes: 9 additions & 0 deletions tests/test_number_spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ def _spell(x):
assert _spell(2001) == "two thousand first"


@pytest.mark.all_rbnf_locales
@pytest.mark.parametrize('ruleset', (None, 'year', 'ordinal'))
def test_spelling_smoke(locale, ruleset):
try:
assert numbers.spell_number(2020, locale=locale, ruleset=ruleset)
except rbnf.RulesetNotFound: # Not all locales have all rulesets, so skip the smoke test.
pass
except RecursionError: # Some combinations currently fail with this :(
pytest.xfail(f'Locale {locale}, ruleset {ruleset}')

# def test_hu_HU_error():
# with pytest.raises(exceptions.TooBigToSpell) as excinfo:
Expand Down

0 comments on commit 9731112

Please sign in to comment.