Commit 7d9a9e50 authored by Gary Poster's avatar Gary Poster

revert revision 72313:

  "add new 64-bit btree types (patch from Jim), merged from trunk"

Even though, as noted in the history file, there is no official release
of standalone ZODB 3.7, it corresponds with the release of Zope 3.3 and
2.10 in 2006, and should be considered feature-frozen.  Jim has
requested that these changes be reserved for the trunk (to be ZODB 3.8).

A subsequent checkin will clarify the status of 3.7 in HISTORY.txt.
parent 0d40356d
What's new in ZODB3 3.7.0? What's new in ZODB3 3.7.0?
========================== ==========================
Release date: ??? Release date: ???
...@@ -6,11 +5,6 @@ Release date: ??? ...@@ -6,11 +5,6 @@ Release date: ???
BTrees 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 - Support for 64-bit integer keys and values has been provided as a
compile-time option. compile-time option.
......
...@@ -69,7 +69,7 @@ base_btrees_depends = [ ...@@ -69,7 +69,7 @@ base_btrees_depends = [
"src/persistent/cPersistence.h", "src/persistent/cPersistence.h",
] ]
_flavors = {"O": "object", "I": "int", "F": "float", 'L': 'int'} _flavors = {"O": "object", "I": "int", "F": "float"}
KEY_H = "src/BTrees/%skeymacros.h" KEY_H = "src/BTrees/%skeymacros.h"
VALUE_H = "src/BTrees/%svaluemacros.h" VALUE_H = "src/BTrees/%svaluemacros.h"
...@@ -88,9 +88,7 @@ def BTreeExtension(flavor): ...@@ -88,9 +88,7 @@ def BTreeExtension(flavor):
return Extension(name, sources, **kwargs) return Extension(name, sources, **kwargs)
exts = [BTreeExtension(flavor) exts = [BTreeExtension(flavor)
for flavor in ("OO", "IO", "OI", "II", "IF", for flavor in ("OO", "IO", "OI", "II", "IF", "fs")]
"fs", "LO", "OL", "LL", "LF",
)]
cPersistence = Extension(name = 'persistent.cPersistence', cPersistence = Extension(name = 'persistent.cPersistence',
include_dirs = include, include_dirs = include,
......
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# hack to overcome dynamic-linking headache.
from _LFBTree import *
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# hack to overcome dynamic-linking headache.
from _LLBTree import *
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# hack to overcome dynamic-linking headache.
from _LOBTree import *
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# hack to overcome dynamic-linking headache.
from _OLBTree import *
...@@ -118,83 +118,3 @@ ...@@ -118,83 +118,3 @@
depends-on TreeSetTemplate.c depends-on TreeSetTemplate.c
depends-on sorters.c depends-on sorters.c
</extension> </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>
/*############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################*/
#define MASTER_ID "$Id: _IFBTree.c 67074 2006-04-17 19:13:39Z fdrake $\n"
/* IFBTree - int key, float value BTree
Implements a collection using int type keys
and float type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "LF"
#define INITMODULE init_LFBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#include "intkeymacros.h"
#include "floatvaluemacros.h"
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################*/
#define MASTER_ID "$Id: _IIBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
/* IIBTree - int key, int value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "LL"
#define INITMODULE init_LLBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#include "intkeymacros.h"
#include "intvaluemacros.h"
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################*/
#define MASTER_ID "$Id: _IOBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
/* IOBTree - int key, object value BTree
Implements a collection using int type keys
and object type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "LO"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 500
#define INITMODULE init_LOBTree
#define ZODB_64BIT_INTS
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################*/
#define MASTER_ID "$Id: _OIBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
/* OIBTree - object key, int value BTree
Implements a collection using object type keys
and int type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "OL"
#define INITMODULE init_OLBTree
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 250
#define ZODB_64BIT_INTS
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#include "BTreeModuleTemplate.c"
...@@ -39,27 +39,35 @@ from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet ...@@ -39,27 +39,35 @@ from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet 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 from ZODB.utils import positive_id, oid_repr
TYPE_UNKNOWN, TYPE_BTREE, TYPE_BUCKET = range(3) TYPE_UNKNOWN, TYPE_BTREE, TYPE_BUCKET = range(3)
_type2kind = {} _type2kind = {IOBTree: (TYPE_BTREE, True),
for kv in ('OO', IIBTree: (TYPE_BTREE, True),
'II', 'IO', 'OI', 'IF', IFBTree: (TYPE_BTREE, True),
'LL', 'LO', 'OL', 'LF', OIBTree: (TYPE_BTREE, True),
): OOBTree: (TYPE_BTREE, True),
for name, kind in (
('BTree', (TYPE_BTREE, True)), IOBucket: (TYPE_BUCKET, True),
('Bucket', (TYPE_BUCKET, True)), IIBucket: (TYPE_BUCKET, True),
('TreeSet', (TYPE_BTREE, False)), IFBucket: (TYPE_BUCKET, True),
('Set', (TYPE_BUCKET, False)), OIBucket: (TYPE_BUCKET, True),
): OOBucket: (TYPE_BUCKET, True),
_type2kind[globals()[kv+name]] = kind
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 # Return pair
# #
...@@ -109,13 +117,20 @@ BTREE_EMPTY, BTREE_ONE, BTREE_NORMAL = range(3) ...@@ -109,13 +117,20 @@ BTREE_EMPTY, BTREE_ONE, BTREE_NORMAL = range(3)
# self->firstbucket # self->firstbucket
# ) # )
_btree2bucket = {} _btree2bucket = {IOBTree: IOBucket,
for kv in ('OO', IOTreeSet: IOSet,
'II', 'IO', 'OI', 'IF',
'LL', 'LO', 'OL', 'LF', IIBTree: IIBucket,
): IITreeSet: IISet,
_btree2bucket[globals()[kv+'BTree']] = globals()[kv+'Bucket']
_btree2bucket[globals()[kv+'TreeSet']] = globals()[kv+'Set'] IFBTree: IFBucket,
IFTreeSet: IFSet,
OIBTree: OIBucket,
OITreeSet: OISet,
OOBTree: OOBucket,
OOTreeSet: OOSet}
def crack_btree(t, is_mapping): def crack_btree(t, is_mapping):
state = t.__getstate__() state = t.__getstate__()
......
...@@ -13,17 +13,12 @@ ...@@ -13,17 +13,12 @@
############################################################################## ##############################################################################
import random import random
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
from types import ClassType
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet 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.IIBTree import using64bits
from BTrees.check import check from BTrees.check import check
...@@ -37,9 +32,6 @@ class Base(TestCase): ...@@ -37,9 +32,6 @@ class Base(TestCase):
db = None db = None
def setUp(self):
self.t = self.t_class()
def tearDown(self): def tearDown(self):
if self.db is not None: if self.db is not None:
self.db.close() self.db.close()
...@@ -1557,79 +1549,86 @@ class DegenerateBTree(TestCase): ...@@ -1557,79 +1549,86 @@ class DegenerateBTree(TestCase):
# at some unrelated line. # at some unrelated line.
del t # trigger destructor 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 BugFixes(TestCase): 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 IISetTest(ExtendedSetTests):
def setUp(self):
self.t = IISet()
# Collector 1843. Error returns were effectively ignored in # Collector 1843. Error returns were effectively ignored in
# Bucket_rangeSearch(), leading to "delayed" errors, or worse. # Bucket_rangeSearch(), leading to "delayed" errors, or worse.
def testFixed1843(self): def testNonIntKeyRaises(self):
t = IISet() self.t.insert(1)
t.insert(1)
# This one used to fail to raise the TypeError when it occurred. # This one used to fail to raise the TypeError when it occurred.
self.assertRaises(TypeError, t.keys, "") self.assertRaises(TypeError, self.t.keys, "")
# This one used to segfault. # This one used to segfault.
self.assertRaises(TypeError, t.keys, 0, "") self.assertRaises(TypeError, self.t.keys, 0, "")
class IFSetTest(ExtendedSetTests):
class IIBTreeTest(BTreeTests):
def setUp(self):
self.t = IIBTree()
class IFBTreeTest(BTreeTests):
def setUp(self): def setUp(self):
self.t = IFBTree() self.t = IFSet()
class IOBTreeTest(BTreeTests): class IOSetTest(ExtendedSetTests):
def setUp(self): def setUp(self):
self.t = IOBTree() self.t = IOSet()
class OIBTreeTest(BTreeTests): class OISetTest(ExtendedSetTests):
def setUp(self): def setUp(self):
self.t = OIBTree() self.t = OISet()
class OOBTreeTest(BTreeTests): class OOSetTest(ExtendedSetTests):
def setUp(self): def setUp(self):
self.t = OOBTree() self.t = OOSet()
if using64bits: class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
def setUp(self): def setUp(self):
self.t = IIBTree() self.t = IIBTree()
def getTwoValues(self): def getTwoValues(self):
return 1, 2 return 1, 2
class IFBTreeTest(BTreeTests, TestLongIntKeys): class IFBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self): def setUp(self):
self.t = IFBTree() self.t = IFBTree()
def getTwoValues(self): def getTwoValues(self):
return 0.5, 1.5 return 0.5, 1.5
class IOBTreeTest(BTreeTests, TestLongIntKeys): class IOBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self): def setUp(self):
self.t = IOBTree() self.t = IOBTree()
class OIBTreeTest(BTreeTests, TestLongIntValues): class OIBTreeTest(BTreeTests, TestLongIntValues):
def setUp(self): def setUp(self):
self.t = OIBTree() self.t = OIBTree()
def getTwoKeys(self): def getTwoKeys(self):
return object(), object() return object(), object()
class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
def setUp(self):
self.t = LLBTree()
def getTwoValues(self):
return 1, 2
class LFBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self):
self.t = LFBTree()
def getTwoValues(self):
return 0.5, 1.5
class LOBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self):
self.t = LOBTree()
class OLBTreeTest(BTreeTests, TestLongIntValues):
def setUp(self):
self.t = OLBTree()
def getTwoKeys(self):
return object(), object()
class OOBTreeTest(BTreeTests): class OOBTreeTest(BTreeTests):
def setUp(self): def setUp(self):
self.t = OOBTree() self.t = OOBTree()
# cmp error propagation tests # cmp error propagation tests
class DoesntLikeBeingCompared: class DoesntLikeBeingCompared:
...@@ -1651,22 +1650,12 @@ class TestCmpError(TestCase): ...@@ -1651,22 +1650,12 @@ class TestCmpError(TestCase):
def test_suite(): def test_suite():
s = TestSuite() 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 ( for klass in (
IIBTreeTest, IFBTreeTest, IOBTreeTest, OIBTreeTest, IIBucketTest, IIBTreeTest, IISetTest, IITreeSetTest,
LLBTreeTest, LFBTreeTest, LOBTreeTest, OLBTreeTest, IFBucketTest, IFBTreeTest, IFSetTest, IFTreeSetTest,
OOBTreeTest, IOBucketTest, IOBTreeTest, IOSetTest, IOTreeSetTest,
OOBucketTest, OOBTreeTest, OOSetTest, OOTreeSetTest,
OIBucketTest, OIBTreeTest, OISetTest, OITreeSetTest,
# Note: there is no TestOOBTrees. The next three are # Note: there is no TestOOBTrees. The next three are
# checking for assorted TypeErrors, and when both keys # checking for assorted TypeErrors, and when both keys
...@@ -1674,9 +1663,7 @@ def test_suite(): ...@@ -1674,9 +1663,7 @@ def test_suite():
TestIIBTrees, TestIFBTrees, TestIOBTrees, TestOIBTrees, TestIIBTrees, TestIFBTrees, TestIOBTrees, TestOIBTrees,
TestIOSets, TestIOSets,
DegenerateBTree, DegenerateBTree,
TestCmpError, TestCmpError):
BugFixes,
):
s.addTest(makeSuite(klass)) s.addTest(makeSuite(klass))
return s return s
......
...@@ -13,17 +13,12 @@ ...@@ -13,17 +13,12 @@
############################################################################## ##############################################################################
import os import os
from unittest import TestCase, TestSuite, makeSuite from unittest import TestCase, TestSuite, makeSuite
from types import ClassType
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet 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 import transaction
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -33,9 +28,6 @@ class Base: ...@@ -33,9 +28,6 @@ class Base:
storage = None storage = None
def setUp(self):
self.t = self.t_type()
def tearDown(self): def tearDown(self):
transaction.abort() transaction.abort()
del self.t del self.t
...@@ -330,6 +322,98 @@ def test_merge(o1, o2, o3, expect, message='failed to merge', should_fail=0): ...@@ -330,6 +322,98 @@ def test_merge(o1, o2, o3, expect, message='failed to merge', should_fail=0):
merged = o1._p_resolveConflict(s1, s2, s3) merged = o1._p_resolveConflict(s1, s2, s3)
assert merged == expected, message 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): class NastyConfict(Base, TestCase):
def setUp(self): def setUp(self):
self.t = OOBTree() self.t = OOBTree()
...@@ -762,19 +846,12 @@ class NastyConfict(Base, TestCase): ...@@ -762,19 +846,12 @@ class NastyConfict(Base, TestCase):
def test_suite(): def test_suite():
suite = TestSuite() suite = TestSuite()
for k in (
for kv in ('OO', TestIIBTrees, TestIISets, TestIITreeSets, TestIIBuckets,
'II', 'IO', 'OI', 'IF', TestIFBTrees, TestIFSets, TestIFTreeSets, TestIFBuckets,
'LL', 'LO', 'OL', 'LF', TestIOBTrees, TestIOSets, TestIOTreeSets, TestIOBuckets,
): TestOOBTrees, TestOOSets, TestOOTreeSets, TestOOBuckets,
for name, bases in (('BTree', (MappingBase, TestCase)), TestOIBTrees, TestOISets, TestOITreeSets, TestOIBuckets,
('Bucket', (MappingBase, TestCase)), NastyConfict):
('TreeSet', (SetTests, TestCase)), suite.addTest(makeSuite(k))
('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 return suite
...@@ -15,13 +15,8 @@ from unittest import TestCase, TestSuite, TextTestRunner, makeSuite ...@@ -15,13 +15,8 @@ from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet 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.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet 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: # Subclasses have to set up:
# builders - functions to build inputs, taking an optional keys arg # builders - functions to build inputs, taking an optional keys arg
...@@ -174,10 +169,6 @@ def makeBuilder(mapbuilder): ...@@ -174,10 +169,6 @@ def makeBuilder(mapbuilder):
return mapbuilder(zip(keys, keys)) return mapbuilder(zip(keys, keys))
return result return result
class PureOO(SetResult):
from BTrees.OOBTree import union, intersection, difference
builders = OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
class PureII(SetResult): class PureII(SetResult):
from BTrees.IIBTree import union, intersection, difference from BTrees.IIBTree import union, intersection, difference
builders = IISet, IITreeSet, makeBuilder(IIBTree), makeBuilder(IIBucket) builders = IISet, IITreeSet, makeBuilder(IIBTree), makeBuilder(IIBucket)
...@@ -186,30 +177,14 @@ class PureIO(SetResult): ...@@ -186,30 +177,14 @@ class PureIO(SetResult):
from BTrees.IOBTree import union, intersection, difference from BTrees.IOBTree import union, intersection, difference
builders = IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket) builders = IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket)
class PureIF(SetResult): class PureOO(SetResult):
from BTrees.IFBTree import union, intersection, difference from BTrees.OOBTree import union, intersection, difference
builders = IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket) builders = OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
class PureOI(SetResult): class PureOI(SetResult):
from BTrees.OIBTree import union, intersection, difference from BTrees.OIBTree import union, intersection, difference
builders = OISet, OITreeSet, makeBuilder(OIBTree), makeBuilder(OIBucket) 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): # Subclasses must set up (as class variables):
# multiunion, union # multiunion, union
# mkset, mktreeset # mkset, mktreeset
...@@ -286,26 +261,6 @@ class TestIOMultiUnion(MultiUnion): ...@@ -286,26 +261,6 @@ class TestIOMultiUnion(MultiUnion):
from BTrees.IOBTree import IOSet as mkset, IOTreeSet as mktreeset from BTrees.IOBTree import IOSet as mkset, IOTreeSet as mktreeset
from BTrees.IOBTree import IOBucket as mkbucket, IOBTree as mkbtree 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 # Check that various special module functions are and aren't imported from
# the expected BTree modules. # the expected BTree modules.
class TestImports(TestCase): class TestImports(TestCase):
...@@ -320,16 +275,6 @@ class TestImports(TestCase): ...@@ -320,16 +275,6 @@ class TestImports(TestCase):
else: else:
self.fail("IOBTree shouldn't have weightedUnion") 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: try:
from BTrees.OOBTree import weightedUnion from BTrees.OOBTree import weightedUnion
except ImportError: except ImportError:
...@@ -348,16 +293,6 @@ class TestImports(TestCase): ...@@ -348,16 +293,6 @@ class TestImports(TestCase):
else: else:
self.fail("IOBTree shouldn't have weightedIntersection") 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: try:
from BTrees.OOBTree import weightedIntersection from BTrees.OOBTree import weightedIntersection
except ImportError: except ImportError:
...@@ -376,16 +311,6 @@ class TestImports(TestCase): ...@@ -376,16 +311,6 @@ class TestImports(TestCase):
else: else:
self.fail("OIBTree shouldn't have multiunion") 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: try:
from BTrees.OOBTree import multiunion from BTrees.OOBTree import multiunion
except ImportError: except ImportError:
...@@ -537,18 +462,6 @@ class TestWeightedOI(Weighted): ...@@ -537,18 +462,6 @@ class TestWeightedOI(Weighted):
from BTrees.OIBTree import OIBucket as mkbucket from BTrees.OIBTree import OIBucket as mkbucket
builders = OIBucket, OIBTree, itemsToSet(OISet), itemsToSet(OITreeSet) 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 # 'thing' is a bucket, btree, set or treeset. Return true iff it's one of the
# latter two. # latter two.
...@@ -558,16 +471,10 @@ def isaset(thing): ...@@ -558,16 +471,10 @@ def isaset(thing):
def test_suite(): def test_suite():
s = TestSuite() s = TestSuite()
for klass in ( for klass in (TestIIMultiUnion, TestIOMultiUnion,
TestIIMultiUnion, TestIOMultiUnion, TestIFMultiUnion,
TestLLMultiUnion, TestLOMultiUnion, TestLFMultiUnion,
TestImports, TestImports,
PureOO, PureII, PureIO, PureOI, PureOO,
PureII, PureIO, PureIF, PureOI, TestWeightedII, TestWeightedOI):
PureLL, PureLO, PureLF, PureOL,
TestWeightedII, TestWeightedOI,
TestWeightedLL, TestWeightedOL,
):
s.addTest(makeSuite(klass)) s.addTest(makeSuite(klass))
return s return s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment