[Zodb-checkins] SVN: ZODB/branches/3.7/ add new 64-bit btree types (patch from Jim), merged from trunk

Fred L. Drake, Jr. fdrake at gmail.com
Thu Feb 1 17:06:01 EST 2007


Log message for revision 72313:
  add new 64-bit btree types (patch from Jim), merged from trunk

Changed:
  U   ZODB/branches/3.7/HISTORY.txt
  U   ZODB/branches/3.7/setup.py
  A   ZODB/branches/3.7/src/BTrees/LFBTree.py
  A   ZODB/branches/3.7/src/BTrees/LLBTree.py
  A   ZODB/branches/3.7/src/BTrees/LOBTree.py
  A   ZODB/branches/3.7/src/BTrees/OLBTree.py
  U   ZODB/branches/3.7/src/BTrees/SETUP.cfg
  A   ZODB/branches/3.7/src/BTrees/_LFBTree.c
  A   ZODB/branches/3.7/src/BTrees/_LLBTree.c
  A   ZODB/branches/3.7/src/BTrees/_LOBTree.c
  A   ZODB/branches/3.7/src/BTrees/_OLBTree.c
  U   ZODB/branches/3.7/src/BTrees/check.py
  U   ZODB/branches/3.7/src/BTrees/tests/testBTrees.py
  U   ZODB/branches/3.7/src/BTrees/tests/testConflict.py
  U   ZODB/branches/3.7/src/BTrees/tests/testSetOps.py

-=-
Modified: ZODB/branches/3.7/HISTORY.txt
===================================================================
--- ZODB/branches/3.7/HISTORY.txt	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/HISTORY.txt	2007-02-01 22:05:59 UTC (rev 72313)
@@ -1,3 +1,4 @@
+
 What's new in ZODB3 3.7.0?
 ==========================
 Release date: ???
@@ -5,6 +6,11 @@
 BTrees
 ------
 
+- Added support for 64-bit integer BTrees as separate types.  
+
+  (For now, we're retaining compile-time support for making the
+   regular integer BTrees 64-bit.)
+
 - Support for 64-bit integer keys and values has been provided as a
   compile-time option.
 

Modified: ZODB/branches/3.7/setup.py
===================================================================
--- ZODB/branches/3.7/setup.py	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/setup.py	2007-02-01 22:05:59 UTC (rev 72313)
@@ -69,7 +69,7 @@
     "src/persistent/cPersistence.h",
     ]
 
-_flavors = {"O": "object", "I": "int", "F": "float"}
+_flavors = {"O": "object", "I": "int", "F": "float", 'L': 'int'}
 
 KEY_H = "src/BTrees/%skeymacros.h"
 VALUE_H = "src/BTrees/%svaluemacros.h"
@@ -88,7 +88,9 @@
     return Extension(name, sources, **kwargs)
 
 exts = [BTreeExtension(flavor)
-        for flavor in ("OO", "IO", "OI", "II", "IF", "fs")]
+        for flavor in ("OO", "IO", "OI", "II", "IF",
+                       "fs", "LO", "OL", "LL", "LF",
+                       )]
 
 cPersistence = Extension(name = 'persistent.cPersistence',
                          include_dirs = include,

Copied: ZODB/branches/3.7/src/BTrees/LFBTree.py (from rev 72267, ZODB/trunk/src/BTrees/LFBTree.py)

Copied: ZODB/branches/3.7/src/BTrees/LLBTree.py (from rev 72267, ZODB/trunk/src/BTrees/LLBTree.py)

Copied: ZODB/branches/3.7/src/BTrees/LOBTree.py (from rev 72267, ZODB/trunk/src/BTrees/LOBTree.py)

Copied: ZODB/branches/3.7/src/BTrees/OLBTree.py (from rev 72267, ZODB/trunk/src/BTrees/OLBTree.py)

Modified: ZODB/branches/3.7/src/BTrees/SETUP.cfg
===================================================================
--- ZODB/branches/3.7/src/BTrees/SETUP.cfg	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/src/BTrees/SETUP.cfg	2007-02-01 22:05:59 UTC (rev 72313)
@@ -118,3 +118,83 @@
   depends-on TreeSetTemplate.c
   depends-on sorters.c
 </extension>
+
+
+<extension _LFBTree>
+  source     _LFBTree.c
+
+  # Specialization:
+  depends-on objectkeymacros.h
+  depends-on objectvaluemacros.h
+
+  # Common btree includes:
+  depends-on BTreeItemsTemplate.c
+  depends-on BTreeModuleTemplate.c
+  depends-on BTreeTemplate.c
+  depends-on BucketTemplate.c
+  depends-on MergeTemplate.c
+  depends-on SetOpTemplate.c
+  depends-on SetTemplate.c
+  depends-on TreeSetTemplate.c
+  depends-on sorters.c
+</extension>
+
+
+<extension _LLBTree>
+  source     _LLBTree.c
+
+  # Specialization:
+  depends-on objectkeymacros.h
+  depends-on objectvaluemacros.h
+
+  # Common btree includes:
+  depends-on BTreeItemsTemplate.c
+  depends-on BTreeModuleTemplate.c
+  depends-on BTreeTemplate.c
+  depends-on BucketTemplate.c
+  depends-on MergeTemplate.c
+  depends-on SetOpTemplate.c
+  depends-on SetTemplate.c
+  depends-on TreeSetTemplate.c
+  depends-on sorters.c
+</extension>
+
+
+<extension _LOBTree>
+  source     _LOBTree.c
+
+  # Specialization:
+  depends-on objectkeymacros.h
+  depends-on objectvaluemacros.h
+
+  # Common btree includes:
+  depends-on BTreeItemsTemplate.c
+  depends-on BTreeModuleTemplate.c
+  depends-on BTreeTemplate.c
+  depends-on BucketTemplate.c
+  depends-on MergeTemplate.c
+  depends-on SetOpTemplate.c
+  depends-on SetTemplate.c
+  depends-on TreeSetTemplate.c
+  depends-on sorters.c
+</extension>
+
+
+<extension _OLBTree>
+  source     _OLBTree.c
+
+  # Specialization:
+  depends-on objectkeymacros.h
+  depends-on objectvaluemacros.h
+
+  # Common btree includes:
+  depends-on BTreeItemsTemplate.c
+  depends-on BTreeModuleTemplate.c
+  depends-on BTreeTemplate.c
+  depends-on BucketTemplate.c
+  depends-on MergeTemplate.c
+  depends-on SetOpTemplate.c
+  depends-on SetTemplate.c
+  depends-on TreeSetTemplate.c
+  depends-on sorters.c
+</extension>

Copied: ZODB/branches/3.7/src/BTrees/_LFBTree.c (from rev 72267, ZODB/trunk/src/BTrees/_LFBTree.c)

Copied: ZODB/branches/3.7/src/BTrees/_LLBTree.c (from rev 72267, ZODB/trunk/src/BTrees/_LLBTree.c)

Copied: ZODB/branches/3.7/src/BTrees/_LOBTree.c (from rev 72267, ZODB/trunk/src/BTrees/_LOBTree.c)

Copied: ZODB/branches/3.7/src/BTrees/_OLBTree.c (from rev 72267, ZODB/trunk/src/BTrees/_OLBTree.c)

Modified: ZODB/branches/3.7/src/BTrees/check.py
===================================================================
--- ZODB/branches/3.7/src/BTrees/check.py	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/src/BTrees/check.py	2007-02-01 22:05:59 UTC (rev 72313)
@@ -39,36 +39,28 @@
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
+from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
 
 from ZODB.utils import positive_id, oid_repr
 
 TYPE_UNKNOWN, TYPE_BTREE, TYPE_BUCKET = range(3)
 
-_type2kind = {IOBTree: (TYPE_BTREE, True),
-              IIBTree: (TYPE_BTREE, True),
-              IFBTree: (TYPE_BTREE, True),
-              OIBTree: (TYPE_BTREE, True),
-              OOBTree: (TYPE_BTREE, True),
+_type2kind = {}
+for kv in ('OO',
+           'II', 'IO', 'OI', 'IF',
+           'LL', 'LO', 'OL', 'LF',
+           ):
+    for name, kind in (
+        ('BTree', (TYPE_BTREE, True)),
+        ('Bucket', (TYPE_BUCKET, True)),
+        ('TreeSet', (TYPE_BTREE, False)),
+        ('Set', (TYPE_BUCKET, False)),
+        ):
+        _type2kind[globals()[kv+name]] = kind
 
-              IOBucket: (TYPE_BUCKET, True),
-              IIBucket: (TYPE_BUCKET, True),
-              IFBucket: (TYPE_BUCKET, True),
-              OIBucket: (TYPE_BUCKET, True),
-              OOBucket: (TYPE_BUCKET, True),
-
-              IOTreeSet: (TYPE_BTREE, False),
-              IITreeSet: (TYPE_BTREE, False),
-              IFTreeSet: (TYPE_BTREE, False),
-              OITreeSet: (TYPE_BTREE, False),
-              OOTreeSet: (TYPE_BTREE, False),
-
-              IOSet: (TYPE_BUCKET, False),
-              IISet: (TYPE_BUCKET, False),
-              IFSet: (TYPE_BUCKET, False),
-              OISet: (TYPE_BUCKET, False),
-              OOSet: (TYPE_BUCKET, False),
-             }
-
 # Return pair
 #
 #     TYPE_BTREE or TYPE_BUCKET, is_mapping
@@ -117,21 +109,14 @@
 #          self->firstbucket
 #     )
 
-_btree2bucket = {IOBTree: IOBucket,
-                 IOTreeSet: IOSet,
+_btree2bucket = {}
+for kv in ('OO',
+           'II', 'IO', 'OI', 'IF',
+           'LL', 'LO', 'OL', 'LF',
+           ):
+    _btree2bucket[globals()[kv+'BTree']] = globals()[kv+'Bucket']
+    _btree2bucket[globals()[kv+'TreeSet']] = globals()[kv+'Set']
 
-                 IIBTree: IIBucket,
-                 IITreeSet: IISet,
-
-                 IFBTree: IFBucket,
-                 IFTreeSet: IFSet,
-
-                 OIBTree: OIBucket,
-                 OITreeSet: OISet,
-
-                 OOBTree: OOBucket,
-                 OOTreeSet: OOSet}
-
 def crack_btree(t, is_mapping):
     state = t.__getstate__()
     if state is None:

Modified: ZODB/branches/3.7/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/branches/3.7/src/BTrees/tests/testBTrees.py	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/src/BTrees/tests/testBTrees.py	2007-02-01 22:05:59 UTC (rev 72313)
@@ -13,12 +13,17 @@
 ##############################################################################
 import random
 from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
+from types import ClassType
 
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
+from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
 
 from BTrees.IIBTree import using64bits
 from BTrees.check import check
@@ -32,6 +37,9 @@
 
     db = None
 
+    def setUp(self):
+        self.t = self.t_class()
+
     def tearDown(self):
         if self.db is not None:
             self.db.close()
@@ -1549,86 +1557,79 @@
             # at some unrelated line.
             del t   # trigger destructor
 
-class IIBucketTest(MappingBase):
-    def setUp(self):
-        self.t = IIBucket()
-class IFBucketTest(MappingBase):
-    def setUp(self):
-        self.t = IFBucket()
-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()
 
-class IITreeSetTest(NormalSetTests):
-    def setUp(self):
-        self.t = IITreeSet()
-class IFTreeSetTest(NormalSetTests):
-    def setUp(self):
-        self.t = IFTreeSet()
-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()
+class BugFixes(TestCase):
 
-class IISetTest(ExtendedSetTests):
-    def setUp(self):
-        self.t = IISet()
-
     # Collector 1843.  Error returns were effectively ignored in
     # Bucket_rangeSearch(), leading to "delayed" errors, or worse.
-    def testNonIntKeyRaises(self):
-        self.t.insert(1)
+    def testFixed1843(self):
+        t = IISet()
+        t.insert(1)
         # This one used to fail to raise the TypeError when it occurred.
-        self.assertRaises(TypeError, self.t.keys, "")
+        self.assertRaises(TypeError, t.keys, "")
         # This one used to segfault.
-        self.assertRaises(TypeError, self.t.keys, 0, "")
+        self.assertRaises(TypeError, t.keys, 0, "")
 
-class IFSetTest(ExtendedSetTests):
+
+class IIBTreeTest(BTreeTests):
     def setUp(self):
-        self.t = IFSet()
-class IOSetTest(ExtendedSetTests):
+        self.t = IIBTree()
+class IFBTreeTest(BTreeTests):
     def setUp(self):
-        self.t = IOSet()
-class OISetTest(ExtendedSetTests):
+        self.t = IFBTree()
+class IOBTreeTest(BTreeTests):
     def setUp(self):
-        self.t = OISet()
-class OOSetTest(ExtendedSetTests):
+        self.t = IOBTree()
+class OIBTreeTest(BTreeTests):
     def setUp(self):
-        self.t = OOSet()
+        self.t = OIBTree()
+class OOBTreeTest(BTreeTests):
+    def setUp(self):
+        self.t = OOBTree()
 
-class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
+if using64bits:
+    class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
+        def setUp(self):
+            self.t = IIBTree()
+        def getTwoValues(self):
+            return 1, 2
+    class IFBTreeTest(BTreeTests, TestLongIntKeys):
+        def setUp(self):
+            self.t = IFBTree()
+        def getTwoValues(self):
+            return 0.5, 1.5
+    class IOBTreeTest(BTreeTests, TestLongIntKeys):
+        def setUp(self):
+            self.t = IOBTree()
+    class OIBTreeTest(BTreeTests, TestLongIntValues):
+        def setUp(self):
+            self.t = OIBTree()
+        def getTwoKeys(self):
+            return object(), object()
+    
+class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
     def setUp(self):
-        self.t = IIBTree()
+        self.t = LLBTree()
     def getTwoValues(self):
         return 1, 2
-class IFBTreeTest(BTreeTests, TestLongIntKeys):
+class LFBTreeTest(BTreeTests, TestLongIntKeys):
     def setUp(self):
-        self.t = IFBTree()
+        self.t = LFBTree()
     def getTwoValues(self):
         return 0.5, 1.5
-class IOBTreeTest(BTreeTests, TestLongIntKeys):
+class LOBTreeTest(BTreeTests, TestLongIntKeys):
     def setUp(self):
-        self.t = IOBTree()
-class OIBTreeTest(BTreeTests, TestLongIntValues):
+        self.t = LOBTree()
+class OLBTreeTest(BTreeTests, TestLongIntValues):
     def setUp(self):
-        self.t = OIBTree()
+        self.t = OLBTree()
     def getTwoKeys(self):
         return object(), object()
 class OOBTreeTest(BTreeTests):
     def setUp(self):
         self.t = OOBTree()
 
+
 # cmp error propagation tests
 
 class DoesntLikeBeingCompared:
@@ -1650,12 +1651,22 @@
 def test_suite():
     s = TestSuite()
 
+    for kv in ('OO',
+               'II', 'IO', 'OI', 'IF',
+               'LL', 'LO', 'OL', 'LF',
+               ):
+        for name, bases in (('Bucket', (MappingBase,)),
+                            ('TreeSet', (NormalSetTests,)),
+                            ('Set', (ExtendedSetTests,)),
+                            ):
+            klass = ClassType(kv + name + 'Test', bases,
+                              dict(t_class=globals()[kv+name]))
+            s.addTest(makeSuite(klass))
+
     for klass in (
-        IIBucketTest, IIBTreeTest, IISetTest, IITreeSetTest,
-        IFBucketTest, IFBTreeTest, IFSetTest, IFTreeSetTest,
-        IOBucketTest, IOBTreeTest, IOSetTest, IOTreeSetTest,
-        OOBucketTest, OOBTreeTest, OOSetTest, OOTreeSetTest,
-        OIBucketTest, OIBTreeTest, OISetTest, OITreeSetTest,
+        IIBTreeTest, IFBTreeTest, IOBTreeTest, OIBTreeTest,
+        LLBTreeTest, LFBTreeTest, LOBTreeTest, OLBTreeTest,
+        OOBTreeTest,
 
         # Note:  there is no TestOOBTrees.  The next three are
         # checking for assorted TypeErrors, and when both keys
@@ -1663,7 +1674,9 @@
         TestIIBTrees, TestIFBTrees,  TestIOBTrees,  TestOIBTrees,
         TestIOSets,
         DegenerateBTree,
-        TestCmpError):
+        TestCmpError,
+        BugFixes,
+        ):
         s.addTest(makeSuite(klass))
 
     return s

Modified: ZODB/branches/3.7/src/BTrees/tests/testConflict.py
===================================================================
--- ZODB/branches/3.7/src/BTrees/tests/testConflict.py	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/src/BTrees/tests/testConflict.py	2007-02-01 22:05:59 UTC (rev 72313)
@@ -13,12 +13,17 @@
 ##############################################################################
 import os
 from unittest import TestCase, TestSuite, makeSuite
+from types import ClassType
 
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
+from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
 
 import transaction
 from ZODB.POSException import ConflictError
@@ -28,6 +33,9 @@
 
     storage = None
 
+    def setUp(self):
+        self.t = self.t_type()
+
     def tearDown(self):
         transaction.abort()
         del self.t
@@ -322,98 +330,6 @@
         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 """
-
-## BTree tests
-
-class TestIOBTrees(BTreeTests, TestCase):
-    def setUp(self):
-        self.t = IOBTree()
-
-class TestOOBTrees(BTreeTests, TestCase):
-    def setUp(self):
-        self.t = OOBTree()
-
-class TestOIBTrees(BTreeTests, TestCase):
-    def setUp(self):
-        self.t = OIBTree()
-
-class TestIIBTrees(BTreeTests, TestCase):
-    def setUp(self):
-        self.t = IIBTree()
-
-class TestIFBTrees(BTreeTests, TestCase):
-    def setUp(self):
-        self.t = IFBTree()
-
-## Set tests
-
-class TestIOSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IOSet()
-
-class TestOOSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = OOSet()
-
-class TestIISets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IISet()
-
-class TestIFSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IFSet()
-
-class TestOISets(SetTests, TestCase):
-    def setUp(self):
-        self.t = OISet()
-
-class TestIOTreeSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IOTreeSet()
-
-class TestOOTreeSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = OOTreeSet()
-
-class TestIITreeSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IITreeSet()
-
-class TestIFTreeSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = IFTreeSet()
-
-class TestOITreeSets(SetTests, TestCase):
-    def setUp(self):
-        self.t = OITreeSet()
-
-## Bucket tests
-
-class TestIOBuckets(BucketTests, TestCase):
-    def setUp(self):
-        self.t = IOBucket()
-
-class TestOOBuckets(BucketTests, TestCase):
-    def setUp(self):
-        self.t = OOBucket()
-
-class TestIIBuckets(BucketTests, TestCase):
-    def setUp(self):
-        self.t = IIBucket()
-
-class TestIFBuckets(BucketTests, TestCase):
-    def setUp(self):
-        self.t = IFBucket()
-
-class TestOIBuckets(BucketTests, TestCase):
-    def setUp(self):
-        self.t = OIBucket()
-
 class NastyConfict(Base, TestCase):
     def setUp(self):
         self.t = OOBTree()
@@ -846,12 +762,19 @@
 
 def test_suite():
     suite = TestSuite()
-    for k in (
-        TestIIBTrees, TestIISets, TestIITreeSets, TestIIBuckets,
-        TestIFBTrees, TestIFSets, TestIFTreeSets, TestIFBuckets,
-        TestIOBTrees, TestIOSets, TestIOTreeSets, TestIOBuckets,
-        TestOOBTrees, TestOOSets, TestOOTreeSets, TestOOBuckets,
-        TestOIBTrees, TestOISets, TestOITreeSets, TestOIBuckets,
-        NastyConfict):
-        suite.addTest(makeSuite(k))
+
+    for kv in ('OO',
+               'II', 'IO', 'OI', 'IF',
+               'LL', 'LO', 'OL', 'LF',
+               ):
+        for name, bases in (('BTree', (MappingBase, TestCase)),
+                            ('Bucket', (MappingBase, TestCase)),
+                            ('TreeSet', (SetTests, TestCase)),
+                            ('Set', (SetTests, TestCase)),
+                            ):
+            klass = ClassType(kv + name + 'Test', bases,
+                              dict(t_type=globals()[kv+name]))
+            suite.addTest(makeSuite(klass))
+    
+    suite.addTest(makeSuite(NastyConfict))
     return suite

Modified: ZODB/branches/3.7/src/BTrees/tests/testSetOps.py
===================================================================
--- ZODB/branches/3.7/src/BTrees/tests/testSetOps.py	2007-02-01 21:56:30 UTC (rev 72312)
+++ ZODB/branches/3.7/src/BTrees/tests/testSetOps.py	2007-02-01 22:05:59 UTC (rev 72313)
@@ -15,8 +15,13 @@
 
 from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
 from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
+from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
 from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
 from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
 
 # Subclasses have to set up:
 #     builders - functions to build inputs, taking an optional keys arg
@@ -169,6 +174,10 @@
         return mapbuilder(zip(keys, keys))
     return result
 
+class PureOO(SetResult):
+    from BTrees.OOBTree import union, intersection, difference
+    builders = OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
+
 class PureII(SetResult):
     from BTrees.IIBTree import union, intersection, difference
     builders = IISet, IITreeSet, makeBuilder(IIBTree), makeBuilder(IIBucket)
@@ -177,14 +186,30 @@
     from BTrees.IOBTree import union, intersection, difference
     builders = IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket)
 
-class PureOO(SetResult):
-    from BTrees.OOBTree import union, intersection, difference
-    builders = OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
+class PureIF(SetResult):
+    from BTrees.IFBTree import union, intersection, difference
+    builders = IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket)
 
 class PureOI(SetResult):
     from BTrees.OIBTree import union, intersection, difference
     builders = OISet, OITreeSet, makeBuilder(OIBTree), makeBuilder(OIBucket)
 
+class PureLL(SetResult):
+    from BTrees.LLBTree import union, intersection, difference
+    builders = LLSet, LLTreeSet, makeBuilder(LLBTree), makeBuilder(LLBucket)
+
+class PureLO(SetResult):
+    from BTrees.LOBTree import union, intersection, difference
+    builders = LOSet, LOTreeSet, makeBuilder(LOBTree), makeBuilder(LOBucket)
+
+class PureLF(SetResult):
+    from BTrees.LFBTree import union, intersection, difference
+    builders = LFSet, LFTreeSet, makeBuilder(LFBTree), makeBuilder(LFBucket)
+
+class PureOL(SetResult):
+    from BTrees.OLBTree import union, intersection, difference
+    builders = OLSet, OLTreeSet, makeBuilder(OLBTree), makeBuilder(OLBucket)
+
 # Subclasses must set up (as class variables):
 #     multiunion, union
 #     mkset, mktreeset
@@ -261,6 +286,26 @@
     from BTrees.IOBTree import IOSet as mkset, IOTreeSet as mktreeset
     from BTrees.IOBTree import IOBucket as mkbucket, IOBTree as mkbtree
 
+class TestIFMultiUnion(MultiUnion):
+    from BTrees.IFBTree import multiunion, union
+    from BTrees.IFBTree import IFSet as mkset, IFTreeSet as mktreeset
+    from BTrees.IFBTree import IFBucket as mkbucket, IFBTree as mkbtree
+
+class TestLLMultiUnion(MultiUnion):
+    from BTrees.LLBTree import multiunion, union
+    from BTrees.LLBTree import LLSet as mkset, LLTreeSet as mktreeset
+    from BTrees.LLBTree import LLBucket as mkbucket, LLBTree as mkbtree
+
+class TestLOMultiUnion(MultiUnion):
+    from BTrees.LOBTree import multiunion, union
+    from BTrees.LOBTree import LOSet as mkset, LOTreeSet as mktreeset
+    from BTrees.LOBTree import LOBucket as mkbucket, LOBTree as mkbtree
+
+class TestLFMultiUnion(MultiUnion):
+    from BTrees.LFBTree import multiunion, union
+    from BTrees.LFBTree import LFSet as mkset, LFTreeSet as mktreeset
+    from BTrees.LFBTree import LFBucket as mkbucket, LFBTree as mkbtree
+
 # Check that various special module functions are and aren't imported from
 # the expected BTree modules.
 class TestImports(TestCase):
@@ -275,7 +320,17 @@
         else:
             self.fail("IOBTree shouldn't have weightedUnion")
 
+        from BTrees.LLBTree import weightedUnion
+        from BTrees.OLBTree import weightedUnion
+
         try:
+            from BTrees.LOBTree import weightedUnion
+        except ImportError:
+            pass
+        else:
+            self.fail("LOBTree shouldn't have weightedUnion")
+
+        try:
             from BTrees.OOBTree import weightedUnion
         except ImportError:
             pass
@@ -293,7 +348,17 @@
         else:
             self.fail("IOBTree shouldn't have weightedIntersection")
 
+        from BTrees.LLBTree import weightedIntersection
+        from BTrees.OLBTree import weightedIntersection
+
         try:
+            from BTrees.LOBTree import weightedIntersection
+        except ImportError:
+            pass
+        else:
+            self.fail("LOBTree shouldn't have weightedIntersection")
+
+        try:
             from BTrees.OOBTree import weightedIntersection
         except ImportError:
             pass
@@ -311,7 +376,17 @@
         else:
             self.fail("OIBTree shouldn't have multiunion")
 
+        from BTrees.LLBTree import multiunion
+        from BTrees.LOBTree import multiunion
+
         try:
+            from BTrees.OLBTree import multiunion
+        except ImportError:
+            pass
+        else:
+            self.fail("OLBTree shouldn't have multiunion")
+
+        try:
             from BTrees.OOBTree import multiunion
         except ImportError:
             pass
@@ -462,7 +537,19 @@
     from BTrees.OIBTree import OIBucket as mkbucket
     builders = OIBucket, OIBTree, itemsToSet(OISet), itemsToSet(OITreeSet)
 
+class TestWeightedLL(Weighted):
+    from BTrees.LLBTree import weightedUnion, weightedIntersection
+    from BTrees.LLBTree import union, intersection
+    from BTrees.LLBTree import LLBucket as mkbucket
+    builders = LLBucket, LLBTree, itemsToSet(LLSet), itemsToSet(LLTreeSet)
 
+class TestWeightedOL(Weighted):
+    from BTrees.OLBTree import weightedUnion, weightedIntersection
+    from BTrees.OLBTree import union, intersection
+    from BTrees.OLBTree import OLBucket as mkbucket
+    builders = OLBucket, OLBTree, itemsToSet(OLSet), itemsToSet(OLTreeSet)
+
+
 # 'thing' is a bucket, btree, set or treeset.  Return true iff it's one of the
 # latter two.
 def isaset(thing):
@@ -471,10 +558,16 @@
 
 def test_suite():
     s = TestSuite()
-    for klass in (TestIIMultiUnion, TestIOMultiUnion,
-                  TestImports,
-                  PureII, PureIO, PureOI, PureOO,
-                  TestWeightedII, TestWeightedOI):
+    for klass in (
+        TestIIMultiUnion, TestIOMultiUnion, TestIFMultiUnion,
+        TestLLMultiUnion, TestLOMultiUnion, TestLFMultiUnion,
+        TestImports,
+        PureOO,
+        PureII, PureIO, PureIF, PureOI,
+        PureLL, PureLO, PureLF, PureOL,
+        TestWeightedII, TestWeightedOI,
+        TestWeightedLL, TestWeightedOL,
+        ):
         s.addTest(makeSuite(klass))
     return s
 



More information about the Zodb-checkins mailing list