Validate Locale parameter formats while constructing by akx · Pull Request #309 · python-babel/babel · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions babel/core.py
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ def os_environ(monkeypatch):
mock_environ = dict(os.environ)
monkeypatch.setattr(os, 'environ', mock_environ)
return mock_environ


def pytest_generate_tests(metafunc):
if hasattr(metafunc.function, "all_locales"):
from babel.localedata import locale_identifiers
metafunc.parametrize("locale", list(locale_identifiers()))
2 changes: 1 addition & 1 deletion tests/messages/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_2_num_plurals_checkers(self):
num_plurals = PLURALS[_locale][0]
plural_expr = PLURALS[_locale][1]
try:
locale = Locale(_locale)
locale = Locale.parse(_locale)
date = format_datetime(datetime.now(LOCALTZ),
'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale=_locale)
Expand Down
27 changes: 23 additions & 4 deletions tests/test_core.py