[Zope3-checkins] CVS: Zope3/src/zodb/btrees/tests - test_conflict.py:1.3

Jeremy Hylton jeremy@zope.com
Thu, 9 Jan 2003 12:52:00 -0500


Update of /cvs-repository/Zope3/src/zodb/btrees/tests
In directory cvs.zope.org:/tmp/cvs-serv19880/tests

Modified Files:
	test_conflict.py 
Log Message:
Fix all sorts of silly mistakes.

Run some tests for TreeSets.  Make sure that all flavors are tested.

Collapse inheritence chain.  Remove some unused intermediate base classes.


=== Zope3/src/zodb/btrees/tests/test_conflict.py 1.2 => 1.3 ===
--- Zope3/src/zodb/btrees/tests/test_conflict.py:1.2	Wed Dec 25 09:12:17 2002
+++ Zope3/src/zodb/btrees/tests/test_conflict.py	Thu Jan  9 12:51:58 2003
@@ -183,13 +183,7 @@
         test_merge(base, b1, b2, bm, 'merge conflicting inserts',
                    should_fail=1)
 
-
-class NormalSetTests(Base):
-    """ Test common to all set types """
-
-
-
-class ExtendedSetTests(NormalSetTests):
+class SetTests(Base):
     "Set (as opposed to TreeSet) specific tests."
 
     def _setupConflict(self):
@@ -288,27 +282,27 @@
 
 
 def test_merge(o1, o2, o3, expect, message='failed to merge', should_fail=0):
-    s1=o1.__getstate__()
-    s2=o2.__getstate__()
-    s3=o3.__getstate__()
-    expected=expect.__getstate__()
-    if expected is None: expected=((((),),),)
+    s1 = o1.__getstate__()
+    s2 = o2.__getstate__()
+    s3 = o3.__getstate__()
+    expected = expect.__getstate__()
+    if expected is None:
+        expected = ((((),),),)
 
     if should_fail:
         try:
-            merged=o1._p_resolveConflict(s1, s2, s3)
-        except (ConflictError, ValueError), err:
-            pass # ConflictError is the only exception that should occur
+            merged = o1._p_resolveConflict(s1, s2, s3)
+        except ConflictError, err:
+            pass 
         else:
             assert 0, message
     else:
-        merged=o1._p_resolveConflict(s1, s2, s3)
-        assert merged==expected, message
+        merged = o1._p_resolveConflict(s1, s2, s3)
+        assert merged == expected, message
 
 class BucketTests(MappingBase):
     """ Tests common to all buckets """
 
-
 class BTreeTests(MappingBase):
     """ Tests common to all BTrees """
 
@@ -332,35 +326,35 @@
 
 ## Set tests
 
-class TestIOSets(ExtendedSetTests, TestCase):
+class TestIOSets(SetTests, TestCase):
     def setUp(self):
         self.t = IOSet()
 
-class TestOOSets(ExtendedSetTests, TestCase):
+class TestOOSets(SetTests, TestCase):
     def setUp(self):
         self.t = OOSet()
 
-class TestIISets(ExtendedSetTests, TestCase):
+class TestIISets(SetTests, TestCase):
     def setUp(self):
         self.t = IISet()
 
-class TestOISets(ExtendedSetTests, TestCase):
+class TestOISets(SetTests, TestCase):
     def setUp(self):
         self.t = OISet()
 
-class TestIOTreeSets(NormalSetTests, TestCase):
+class TestIOTreeSets(SetTests, TestCase):
     def setUp(self):
         self.t = IOTreeSet()
 
-class TestOOTreeSets(NormalSetTests, TestCase):
+class TestOOTreeSets(SetTests, TestCase):
     def setUp(self):
         self.t = OOTreeSet()
 
-class TestIITreeSets(NormalSetTests, TestCase):
+class TestIITreeSets(SetTests, TestCase):
     def setUp(self):
         self.t = IITreeSet()
 
-class TestOITreeSets(NormalSetTests, TestCase):
+class TestOITreeSets(SetTests, TestCase):
     def setUp(self):
         self.t = OITreeSet()
 
@@ -382,49 +376,15 @@
     def setUp(self):
         self.t = OIBucket()
 
-# XXX disable tests for now
 def test_suite():
-    TIOBTree = makeSuite(TestIOBTrees, 'test')
-    TOOBTree = makeSuite(TestOOBTrees, 'test')
-    TOIBTree = makeSuite(TestOIBTrees, 'test')
-    TIIBTree = makeSuite(TestIIBTrees, 'test')
-
-    TIOSet = makeSuite(TestIOSets, 'test')
-    TOOSet = makeSuite(TestOOSets, 'test')
-    TOISet = makeSuite(TestIOSets, 'test')
-    TIISet = makeSuite(TestOOSets, 'test')
-
-    TIOTreeSet = makeSuite(TestIOTreeSets, 'test')
-    TOOTreeSet = makeSuite(TestOOTreeSets, 'test')
-    TOITreeSet = makeSuite(TestIOTreeSets, 'test')
-    TIITreeSet = makeSuite(TestOOTreeSets, 'test')
-
-    TIOBucket = makeSuite(TestIOBuckets, 'test')
-    TOOBucket = makeSuite(TestOOBuckets, 'test')
-    TOIBucket = makeSuite(TestOIBuckets, 'test')
-    TIIBucket = makeSuite(TestIIBuckets, 'test')
-
-    alltests = TestSuite((TIOSet, TOOSet, TOISet, TIISet,
-                          TIOTreeSet, TOOTreeSet, TOITreeSet, TIITreeSet,
-                          TIOBucket, TOOBucket, TOIBucket, TIIBucket,
-                          TOOBTree, TIOBTree, TOIBTree, TIIBTree))
-
-    return alltests
-
-## utility functions
-
-def lsubtract(l1, l2):
-    l1=list(l1)
-    l2=list(l2)
-    l = filter(lambda x, l1=l1: x not in l1, l2)
-    l = l + filter(lambda x, l2=l2: x not in l2, l1)
-    return l
-
-def realseq(itemsob):
-    return map(lambda x: x, itemsob)
-
-def main():
-    TextTestRunner().run(test_suite())
+    suite = TestSuite()
+    for klass in (TestIOBTrees, TestOOBTrees, TestOIBTrees, TestIIBTrees,
+                  TestIOSets, TestOOSets, TestIOSets, TestIISets,
+                  TestIOTreeSets, TestOOTreeSets, TestOITreeSets,
+                  TestIITreeSets,
+                  TestIOBuckets, TestOOBuckets, TestOIBuckets, TestIIBuckets):
+        s = makeSuite(klass)
+        print klass, s.countTestCases()
+        suite.addTest(makeSuite(klass))
+    return suite
 
-if __name__ == '__main__':
-    main()