Skip to content

Commit

Permalink
Fixed #20502 -- Flushed i18n caches for a defaultfilter test
Browse files Browse the repository at this point in the history
Thanks Chris Wilson for the report and initial patch.
  • Loading branch information
claudep committed May 30, 2013
1 parent 571864c commit 9d06c6c
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions tests/defaultfilters/tests.py
Expand Up @@ -11,6 +11,8 @@
from django.utils.safestring import SafeData
from django.utils.encoding import python_2_unicode_compatible

from i18n import TransRealMixin


class DefaultFiltersTests(TestCase):

Expand Down Expand Up @@ -594,28 +596,6 @@ def test_filesizeformat(self):
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')
Expand Down Expand Up @@ -660,3 +640,27 @@ def test_non_string_input(self):
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')

0 comments on commit 9d06c6c

Please sign in to comment.