diff --git a/django/utils/formats.py b/django/utils/formats.py
index 3babccb..e283490 100644
a
|
b
|
def get_format(format_type, lang=None, use_l10n=None):
|
71 | 71 | lang = get_language() |
72 | 72 | cache_key = (format_type, lang) |
73 | 73 | try: |
74 | | return _format_cache[cache_key] or getattr(settings, format_type) |
| 74 | cached = _format_cache[cache_key] |
| 75 | if cached is not None: |
| 76 | return cached |
| 77 | else: |
| 78 | # Return the general setting by default |
| 79 | return getattr(settings, format_type) |
75 | 80 | except KeyError: |
76 | 81 | for module in get_format_modules(lang): |
77 | 82 | try: |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index bfed0ec..186923d 100644
a
|
b
|
from django.test import TestCase, RequestFactory
|
14 | 14 | from django.test.utils import override_settings |
15 | 15 | from django.utils import translation |
16 | 16 | from django.utils.formats import (get_format, date_format, time_format, |
17 | | localize, localize_input, iter_format_modules, get_format_modules) |
| 17 | localize, localize_input, iter_format_modules, get_format_modules, |
| 18 | number_format) |
18 | 19 | from django.utils.importlib import import_module |
19 | 20 | from django.utils.numberformat import format as nformat |
20 | 21 | from django.utils.safestring import mark_safe, SafeString, SafeUnicode |
… |
… |
class FormattingTests(TestCase):
|
397 | 398 | self.assertEqual(u'66666.67', Template('{{ n|floatformat:2 }}').render(self.ctxt)) |
398 | 399 | self.assertEqual(u'100000.0', Template('{{ f|floatformat }}').render(self.ctxt)) |
399 | 400 | |
| 401 | def test_empty_string_format(self): |
| 402 | """ |
| 403 | Ensure that the active locale's formats take precedence over the |
| 404 | default settings even if they are empty strings. |
| 405 | Refs #16938. |
| 406 | """ |
| 407 | from django.conf.locale.fr import formats as fr_formats |
| 408 | backup = fr_formats.THOUSAND_SEPARATOR |
| 409 | fr_formats.THOUSAND_SEPARATOR = '' |
| 410 | with self.settings(USE_L10N = True, USE_THOUSAND_SEPARATOR=True, |
| 411 | THOUSAND_SEPARATOR='!'): |
| 412 | with translation.override('fr'): |
| 413 | self.assertEqual(number_format(999999), '999999') |
| 414 | # Even a second time (after the format has been cached)... |
| 415 | self.assertEqual(number_format(999999), '999999') |
| 416 | fr_formats.THOUSAND_SEPARATOR = backup |
| 417 | |
400 | 418 | def test_l10n_enabled(self): |
401 | 419 | settings.USE_L10N = True |
402 | 420 | # Catalan locale |