[Zope3-checkins] CVS: Zope3/lib/python/Persistence/BTrees/tests - testBTrees.py:1.21

Tim Peters tim.one@comcast.net
Thu, 8 Aug 2002 11:04:23 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv28756/tests

Modified Files:
	testBTrees.py 
Log Message:
In Python 2.3, unittest just changed to make TestCase a new-style class.
But you can't change the __name__ on one of those, and the BTree tests
try to.  Guido doesn't change the former, so I changed the latter (just
write out the tests needed instead of trying to generate them -- and I
find this clearer anyway, albeit error-prone due to repetition).


=== Zope3/lib/python/Persistence/BTrees/tests/testBTrees.py 1.20 => 1.21 ===
--- Zope3/lib/python/Persistence/BTrees/tests/testBTrees.py:1.20	Wed Jul 24 18:52:50 2002
+++ Zope3/lib/python/Persistence/BTrees/tests/testBTrees.py	Thu Aug  8 11:04:23 2002
@@ -1143,34 +1143,66 @@
             # at some unrelated line.
             del t   # trigger destructor
 
+class IIBucketTest(MappingBase):
+    def setUp(self):
+        self.t = IIBucket()
+class IOBucketTest(MappingBase):
+    def setUp(self):
+        self.t = IOBucket()
+class OIBucketTest(MappingBase):
+    def setUp(self):
+        self.t = OIBucket()
+class OOBucketTest(MappingBase):
+    def setUp(self):
+        self.t = OOBucket()
 
-def make_test(klass, base):
-    class Test(base):
-        def setUp(self):
-            self.t = klass()
-    # Give the test an artificial name so that unittest output
-    # includes the name of the BTree object being tested.  Include a
-    # '!' in the name so that it is obvious that it doesn't occur in
-    # the source code anywhere.
-    Test.__name__ = "!%sTest" % klass.__name__
-    return makeSuite(Test)
+class IITreeSetTest(NormalSetTests):
+    def setUp(self):
+        self.t = IITreeSet()
+class IOTreeSetTest(NormalSetTests):
+    def setUp(self):
+        self.t = IOTreeSet()
+class OITreeSetTest(NormalSetTests):
+    def setUp(self):
+        self.t = OITreeSet()
+class OOTreeSetTest(NormalSetTests):
+    def setUp(self):
+        self.t = OOTreeSet()
 
-def test_suite():
-    # Handle the basic test cases for each type of object via make_test().
-    template = [(MappingBase, (IIBucket, IOBucket, OIBucket, OOBucket)),
-                (NormalSetTests, (IITreeSet, IOTreeSet, OITreeSet, OOTreeSet)),
-                (ExtendedSetTests, (IISet, IOSet, OISet, OOSet)),
-                (BTreeTests, (IIBTree, IOBTree,  OIBTree, OOBTree)),
-                ]
+class IISetTest(ExtendedSetTests):
+    def setUp(self):
+        self.t = IISet()
+class IOSetTest(ExtendedSetTests):
+    def setUp(self):
+        self.t = IOSet()
+class OISetTest(ExtendedSetTests):
+    def setUp(self):
+        self.t = OISet()
+class OOSetTest(ExtendedSetTests):
+    def setUp(self):
+        self.t = OOSet()
+
+class IIBTreeTest(BTreeTests):
+    def setUp(self):
+        self.t = IIBTree()
+class IOBTreeTest(BTreeTests):
+    def setUp(self):
+        self.t = IOBTree()
+class OIBTreeTest(BTreeTests):
+    def setUp(self):
+        self.t = OIBTree()
+class OOBTreeTest(BTreeTests):
+    def setUp(self):
+        self.t = OOBTree()
 
+def test_suite():
     s = TestSuite()
-    for base, classes in template:
-        for klass in classes:
-            s.addTest(make_test(klass, base))
 
-    # Handle the odd assortment of other tests, which appear to be
-    # specific to whether keys and values are Is or Os.
-    for klass in (TestIOBTrees, TestOIBTrees, TestIIBTrees, TestIOSets,
+    for klass in (IIBucketTest, IOBucketTest, OIBucketTest, OOBucketTest,
+                  IITreeSetTest, IOTreeSetTest, OITreeSetTest, OOTreeSetTest,
+                  IISetTest, IOSetTest, OISetTest, OOSetTest,
+                  IIBTreeTest, IOBTreeTest, OIBTreeTest, OOBTreeTest,
+                  TestIOBTrees, TestOIBTrees, TestIIBTrees, TestIOSets,
                   DegenerateBTree):
         s.addTest(makeSuite(klass))