Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #20502 -- Flushed i18n caches for a defaultfilter test

Thanks Chris Wilson for the report and initial patch.
  • Loading branch information...
commit 9d06c6ccc92e240af245205316cf6075b37a24e3 1 parent 571864c
Claude Paroz claudep authored
Showing with 26 additions and 22 deletions.
  1. +26 −22 tests/defaultfilters/tests.py
48 tests/defaultfilters/tests.py
View
@@ -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):
@@ -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')
@@ -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')
Please sign in to comment.
Something went wrong with that request. Please try again.