[Checkins] SVN: Products.ZCatalog/trunk/ Avoid locale-dependent test condition in `test_length_with_filter`.

Hanno Schlichting hannosch at hannosch.eu
Sat Jan 1 09:05:40 EST 2011


Log message for revision 119246:
  Avoid locale-dependent test condition in `test_length_with_filter`.
  

Changed:
  U   Products.ZCatalog/trunk/CHANGES.txt
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_lazy.py

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2010-12-31 20:46:26 UTC (rev 119245)
+++ Products.ZCatalog/trunk/CHANGES.txt	2011-01-01 14:05:40 UTC (rev 119246)
@@ -4,6 +4,7 @@
 2.13.3 (unreleased)
 -------------------
 
+- Avoid locale-dependent test condition in `test_length_with_filter`.
 
 2.13.2 (2010-12-31)
 -------------------

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_lazy.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_lazy.py	2010-12-31 20:46:26 UTC (rev 119245)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_lazy.py	2011-01-01 14:05:40 UTC (rev 119246)
@@ -185,20 +185,21 @@
 
     def test_length_with_filter(self):
         from string import letters
+        lower_length = len([x for x in letters if x.islower()])
 
         # Unaccessed length
         lfilter = self._createLFilter(lambda x: x.islower(), list(letters))
-        self.assertEqual(len(lfilter), 26)
+        self.assertEqual(len(lfilter), lower_length)
 
         # Accessed in the middle
         lfilter = self._createLFilter(lambda x: x.islower(), list(letters))
         lfilter[13]
-        self.assertEqual(len(lfilter), 26)
+        self.assertEqual(len(lfilter), lower_length)
 
         # Accessed after the lcat is accessed over the whole range
         lfilter = self._createLFilter(lambda x: x.islower(), list(letters))
         lfilter[:]
-        self.assertEqual(len(lfilter), 26)
+        self.assertEqual(len(lfilter), lower_length)
 
 
 class TestLazyMop(TestLazyCat):
@@ -227,6 +228,7 @@
 
     def test_length_with_filter(self):
         from string import letters
+        letter_length = len(letters)
 
         seq = range(10) + list(letters)
         def filter(x):
@@ -236,17 +238,17 @@
 
         # Unaccessed length
         lmop = self._createLMop(filter, seq)
-        self.assertEqual(len(lmop), 52)
+        self.assertEqual(len(lmop), letter_length)
 
         # Accessed in the middle
         lmop = self._createLMop(filter, seq)
         lmop[26]
-        self.assertEqual(len(lmop), 52)
+        self.assertEqual(len(lmop), letter_length)
 
         # Accessed after the lcat is accessed over the whole range
         lmop = self._createLMop(filter, letters)
         lmop[:]
-        self.assertEqual(len(lmop), 52)
+        self.assertEqual(len(lmop), letter_length)
 
 
 class TestLazyValues(BaseSequenceTest):



More information about the checkins mailing list