Skip to content

Commit 31815c9

Browse files
committed
Add smoke test for all RBNF-enabled locales and rulesets
1 parent e2bce80 commit 31815c9

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ norecursedirs = venv* .* _* scripts {args}
66
doctest_optionflags = ELLIPSIS NORMALIZE_WHITESPACE ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL
77
markers =
88
all_locales: parameterize test with all locales
9+
all_rbnf_locales: parameterize test with all locales with RBNF rules
910

1011
[bdist_wheel]
1112
universal = 1

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ def pytest_generate_tests(metafunc):
1616
from babel.localedata import locale_identifiers
1717
metafunc.parametrize("locale", list(locale_identifiers()))
1818
break
19+
if mark.name == "all_rbnf_locales":
20+
from babel.core import get_global
21+
metafunc.parametrize("locale", list(get_global('rbnf_locales')))
22+
break

tests/test_number_spelling.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ def _spell(x):
152152
assert _spell(2001) == "two thousand first"
153153

154154

155+
@pytest.mark.all_rbnf_locales
156+
@pytest.mark.parametrize('ruleset', (None, 'year', 'ordinal'))
157+
def test_spelling_smoke(locale, ruleset):
158+
try:
159+
assert numbers.spell_number(2020, locale=locale, ruleset=ruleset)
160+
except rbnf.RulesetNotFound: # Not all locales have all rulesets, so skip the smoke test.
161+
pass
162+
except RecursionError: # Some combinations currently fail with this :(
163+
pytest.xfail('Locale %s, ruleset %s' % (locale, ruleset))
155164

156165
# def test_hu_HU_error():
157166
# with pytest.raises(exceptions.TooBigToSpell) as excinfo:

0 commit comments

Comments
 (0)