from itertools import chain
import sys
-from babel._compat import pickle
+from babel._compat import pickle, string_types
def get_base_dir():
Returns the normalized locale ID string or `None` if the ID is not
recognized.
"""
+ if not name or not isinstance(name, string_types):
+ return None
name = name.strip().lower()
for locale_id in chain.from_iterable([_cache, locale_identifiers()]):
if name == locale_id.lower():
:param name: the locale identifier string
"""
+ if not name or not isinstance(name, string_types):
+ return False
if name in _cache:
return True
file_found = os.path.exists(os.path.join(_dirname, '%s.dat' % name))
from operator import methodcaller
import sys
-from babel import localedata
-
+from babel import localedata, numbers
class MergeResolveTestCase(unittest.TestCase):
for l in localedata.locale_identifiers():
assert localedata.exists(l)
-
def test_unique_ids():
# Check all locale IDs are uniques.
all_ids = localedata.locale_identifiers()
def test_pi_support_not_frozen():
assert not getattr(sys, 'frozen', False)
assert localedata.get_base_dir().endswith('babel')
+
+def test_locale_argument_acceptance():
+ # Testing None input.
+ normalized_locale = localedata.normalize_locale(None)
+ assert normalized_locale == None
+ locale_exist = localedata.exists(None)
+ assert locale_exist == False
+
+ # # Testing list input.
+ normalized_locale = localedata.normalize_locale(['en_us', None])
+ assert normalized_locale == None
+ locale_exist = localedata.exists(['en_us', None])
+ assert locale_exist == False