Skip to content

Commit 7e9c9bc

Browse files
committed
Add smoke test for all RBNF-enabled locales and rulesets
1 parent 8113d1b commit 7e9c9bc

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
@@ -148,6 +148,15 @@ def _spell(x):
148148
assert _spell(2001) == "two thousand first"
149149

150150

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

152161
# def test_hu_HU_error():
153162
# with pytest.raises(exceptions.TooBigToSpell) as excinfo:

0 commit comments

Comments
 (0)