diff --git a/moneyed/localization.py b/moneyed/localization.py index 99f8724..73b0848 100644 --- a/moneyed/localization.py +++ b/moneyed/localization.py @@ -4,7 +4,7 @@ from decimal import Decimal, ROUND_HALF_EVEN import moneyed -DEFAULT = "default" +DEFAULT = "DEFAULT" class CurrencyFormatter(object): @@ -49,11 +49,9 @@ def get_sign_definition(self, currency_code, locale): return ('', " %s" % currency_code) def get_formatting_definition(self, locale): - locale = locale.upper() - if locale in self.formatting_definitions: - return self.formatting_definitions.get(locale) - else: - return self.formatting_definitions.get(DEFAULT) + if locale.upper() not in self.formatting_definitions: + locale = DEFAULT + return self.formatting_definitions.get(locale.upper()) def format(self, money, include_symbol=True, locale=DEFAULT, decimal_places=None, rounding_method=None): diff --git a/moneyed/test_moneyed_classes.py b/moneyed/test_moneyed_classes.py index 04b10bd..3056daf 100644 --- a/moneyed/test_moneyed_classes.py +++ b/moneyed/test_moneyed_classes.py @@ -130,6 +130,8 @@ def test_format_money(self): assert format_money(self.one_million_bucks) == 'US$1,000,000.00' # No decimal point without fractional part assert format_money(self.one_million_bucks, decimal_places=0) == 'US$1,000,000' + # Locale format not included, should fallback to DEFAULT + assert format_money(self.one_million_bucks, locale='es_ES') == 'US$1,000,000.00' # locale == pl_PL one_million_pln = Money('1000000', 'PLN') # Two decimal places by default