Skip to content

Commit 9905dd5

Browse files
akxblagasz
authored andcommitted
Add smoke test for all RBNF-enabled locales and rulesets
1 parent 802e734 commit 9905dd5

File tree

3 files changed

+29
-16
lines changed

3 files changed

+29
-16
lines changed

setup.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1+
<<<<<<< HEAD
2+
=======
3+
[aliases]
4+
release = sdist bdist_wheel
5+
6+
[tool:pytest]
7+
norecursedirs = venv* .* _* scripts {args}
8+
doctest_optionflags = ELLIPSIS NORMALIZE_WHITESPACE ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL
9+
markers =
10+
all_locales: parameterize test with all locales
11+
all_rbnf_locales: parameterize test with all locales with RBNF rules
12+
13+
[bdist_wheel]
14+
universal = 1
15+
16+
>>>>>>> 7e9c9bc (Add smoke test for all RBNF-enabled locales and rulesets)
117
[metadata]
218
license_files = LICENSE

tests/conftest.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,7 @@ def pytest_generate_tests(metafunc):
2121
from babel.localedata import locale_identifiers
2222
metafunc.parametrize("locale", list(locale_identifiers()))
2323
break
24-
25-
26-
@pytest.fixture(params=["pytz.timezone", "zoneinfo.ZoneInfo"], scope="package")
27-
def timezone_getter(request):
28-
if request.param == "pytz.timezone":
29-
if pytz:
30-
return pytz.timezone
31-
else:
32-
pytest.skip("pytz not available")
33-
elif request.param == "zoneinfo.ZoneInfo":
34-
if zoneinfo:
35-
return zoneinfo.ZoneInfo
36-
else:
37-
pytest.skip("zoneinfo not available")
38-
else:
39-
raise NotImplementedError
24+
if mark.name == "all_rbnf_locales":
25+
from babel.core import get_global
26+
metafunc.parametrize("locale", list(get_global('rbnf_locales')))
27+
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)