Fixed #20502 -- Flushed i18n caches for a defaultfilter test
Thanks Chris Wilson for the report and initial patch.
This commit is contained in:
parent
571864c845
commit
9d06c6ccc9
|
@ -11,6 +11,8 @@ from django.utils import unittest, translation
|
|||
from django.utils.safestring import SafeData
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from i18n import TransRealMixin
|
||||
|
||||
|
||||
class DefaultFiltersTests(TestCase):
|
||||
|
||||
|
@ -594,28 +596,6 @@ class DefaultFiltersTests(TestCase):
|
|||
self.assertEqual(filesizeformat("\N{GREEK SMALL LETTER ALPHA}"),
|
||||
'0\xa0bytes')
|
||||
|
||||
def test_localized_filesizeformat(self):
|
||||
# NOTE: \xa0 avoids wrapping between value and unit
|
||||
with self.settings(USE_L10N=True):
|
||||
with translation.override('de', deactivate=True):
|
||||
self.assertEqual(filesizeformat(1023), '1023\xa0Bytes')
|
||||
self.assertEqual(filesizeformat(1024), '1,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(10*1024), '10,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(1024*1024-1), '1024,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(1024*1024), '1,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*50), '50,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024-1), '1024,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024), '1,0\xa0GB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024), '1,0\xa0TB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024),
|
||||
'1,0\xa0PB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
|
||||
'2000,0\xa0PB')
|
||||
self.assertEqual(filesizeformat(complex(1,-1)), '0\xa0Bytes')
|
||||
self.assertEqual(filesizeformat(""), '0\xa0Bytes')
|
||||
self.assertEqual(filesizeformat("\N{GREEK SMALL LETTER ALPHA}"),
|
||||
'0\xa0Bytes')
|
||||
|
||||
def test_pluralize(self):
|
||||
self.assertEqual(pluralize(1), '')
|
||||
self.assertEqual(pluralize(0), 's')
|
||||
|
@ -660,3 +640,27 @@ class DefaultFiltersTests(TestCase):
|
|||
self.assertEqual(removetags(123, 'a'), '123')
|
||||
self.assertEqual(striptags(123), '123')
|
||||
|
||||
|
||||
class DefaultFiltersI18NTests(TransRealMixin, TestCase):
|
||||
|
||||
def test_localized_filesizeformat(self):
|
||||
# NOTE: \xa0 avoids wrapping between value and unit
|
||||
with self.settings(USE_L10N=True):
|
||||
with translation.override('de', deactivate=True):
|
||||
self.assertEqual(filesizeformat(1023), '1023\xa0Bytes')
|
||||
self.assertEqual(filesizeformat(1024), '1,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(10*1024), '10,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(1024*1024-1), '1024,0\xa0KB')
|
||||
self.assertEqual(filesizeformat(1024*1024), '1,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*50), '50,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024-1), '1024,0\xa0MB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024), '1,0\xa0GB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024), '1,0\xa0TB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024),
|
||||
'1,0\xa0PB')
|
||||
self.assertEqual(filesizeformat(1024*1024*1024*1024*1024*2000),
|
||||
'2000,0\xa0PB')
|
||||
self.assertEqual(filesizeformat(complex(1,-1)), '0\xa0Bytes')
|
||||
self.assertEqual(filesizeformat(""), '0\xa0Bytes')
|
||||
self.assertEqual(filesizeformat("\N{GREEK SMALL LETTER ALPHA}"),
|
||||
'0\xa0Bytes')
|
||||
|
|
Loading…
Reference in New Issue