[Zope-Checkins] SVN: Zope/trunk/src/Products/ZCatalog/tests/test_catalog.py Factor out method that needs the warning hook

Hanno Schlichting hannosch at hannosch.eu
Sun Aug 1 12:36:40 EDT 2010


Log message for revision 115339:
  Factor out method that needs the warning hook
  

Changed:
  U   Zope/trunk/src/Products/ZCatalog/tests/test_catalog.py

-=-
Modified: Zope/trunk/src/Products/ZCatalog/tests/test_catalog.py
===================================================================
--- Zope/trunk/src/Products/ZCatalog/tests/test_catalog.py	2010-08-01 16:21:22 UTC (rev 115338)
+++ Zope/trunk/src/Products/ZCatalog/tests/test_catalog.py	2010-08-01 16:36:39 UTC (rev 115339)
@@ -179,7 +179,6 @@
         nums[j] = tmp
 
     def setUp(self):
-        self.warningshook = WarningsHook()
         self._catalog = self._makeOne()
         self._catalog.lexicon = PLexicon('lexicon')
         col1 = FieldIndex('col1')
@@ -214,9 +213,6 @@
             self._catalog.catalogObject(dummy(self.nums[x]), repr(x))
         self._catalog = self._catalog.__of__(dummy('foo'))
 
-    def tearDown(self):
-        self._catalog = None
-
     # clear
     # updateBrains
     # __getitem__
@@ -300,16 +296,6 @@
         self.assertEqual(len(a), self.upper,
                          'length should be %s, its %s' % (self.upper, len(a)))
 
-    def testEmptyMappingReturnsAll(self):
-        self.warningshook.install()
-        try:
-            upper = self.upper
-            length = len(self._catalog({}))
-            self.assertEqual(length, upper,
-                             'length should be %s, its %s' % (upper, length))
-        finally:
-            self.warningshook.uninstall()
-
     def testMappingWithEmptyKeysDoesntReturnAll(self):
         # Queries with empty keys used to return all, because of a bug in the
         # parseIndexRequest function, mistaking a CatalogSearchArgumentsMap
@@ -449,6 +435,27 @@
                              "%d vs [%d,%d]" % (r.number, m, n))
 
 
+class TestCatalogReturnAll(CatalogBase, unittest.TestCase):
+
+    def setUp(self):
+        self.warningshook = WarningsHook()
+        self.warningshook.install()
+        self._catalog = self._makeOne()
+
+    def testEmptyMappingReturnsAll(self):
+        col1 = FieldIndex('col1')
+        self._catalog.addIndex('col1', col1)
+        for x in range(0, 10):
+            self._catalog.catalogObject(dummy(x), repr(x))
+        self.assertEqual(len(self._catalog), 10)
+        length = len(self._catalog({}))
+        self.assertEqual(length, 10)
+
+    def tearDown(self):
+        CatalogBase.tearDown(self)
+        self.warningshook.uninstall()
+
+
 class TestCatalogSearchArgumentsMap(unittest.TestCase):
 
     def _makeOne(self, request=None, keywords=None):
@@ -597,6 +604,7 @@
     suite.addTest(unittest.makeSuite(TestAddDelIndexes))
     suite.addTest(unittest.makeSuite(TestCatalog))
     suite.addTest(unittest.makeSuite(TestRangeSearch))
+    suite.addTest(unittest.makeSuite(TestCatalogReturnAll))
     suite.addTest(unittest.makeSuite(TestCatalogSearchArgumentsMap))
     suite.addTest(unittest.makeSuite(TestMergeResults))
     return suite



More information about the Zope-Checkins mailing list