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?
==========================
Release date: ???
......@@ -6,11 +5,6 @@ Release date: ???
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.
......
......@@ -69,7 +69,7 @@ base_btrees_depends = [
"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"
VALUE_H = "src/BTrees/%svaluemacros.h"
......@@ -88,9 +88,7 @@ def BTreeExtension(flavor):
return Extension(name, sources, **kwargs)
exts = [BTreeExtension(flavor)
for flavor in ("OO", "IO", "OI", "II", "IF",
"fs", "LO", "OL", "LL", "LF",
)]
for flavor in ("OO", "IO", "OI", "II", "IF", "fs")]
cPersistence = Extension(name = 'persistent.cPersistence',
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 @@
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>
/*############################################################################
#
# 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
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 = {}
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
_type2kind = {IOBTree: (TYPE_BTREE, True),
IIBTree: (TYPE_BTREE, True),
IFBTree: (TYPE_BTREE, True),
OIBTree: (TYPE_BTREE, True),
OOBTree: (TYPE_BTREE, True),
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
#
......@@ -109,13 +117,20 @@ BTREE_EMPTY, BTREE_ONE, BTREE_NORMAL = range(3)
# self->firstbucket
# )
_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']
_btree2bucket = {IOBTree: IOBucket,
IOTreeSet: IOSet,
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__()
......
......@@ -13,17 +13,12 @@
##############################################################################
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
......@@ -37,9 +32,6 @@ class Base(TestCase):
db = None
def setUp(self):
self.t = self.t_class()
def tearDown(self):
if self.db is not None:
self.db.close()
......@@ -1557,79 +1549,86 @@ class DegenerateBTree(TestCase):
# 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 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
# Bucket_rangeSearch(), leading to "delayed" errors, or worse.
def testFixed1843(self):
t = IISet()
t.insert(1)
def testNonIntKeyRaises(self):
self.t.insert(1)
# 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.
self.assertRaises(TypeError, t.keys, 0, "")
self.assertRaises(TypeError, self.t.keys, 0, "")
class IIBTreeTest(BTreeTests):
def setUp(self):
self.t = IIBTree()
class IFBTreeTest(BTreeTests):
class IFSetTest(ExtendedSetTests):
def setUp(self):
self.t = IFBTree()
class IOBTreeTest(BTreeTests):
self.t = IFSet()
class IOSetTest(ExtendedSetTests):
def setUp(self):
self.t = IOBTree()
class OIBTreeTest(BTreeTests):
self.t = IOSet()
class OISetTest(ExtendedSetTests):
def setUp(self):
self.t = OIBTree()
class OOBTreeTest(BTreeTests):
self.t = OISet()
class OOSetTest(ExtendedSetTests):
def setUp(self):
self.t = OOBTree()
self.t = OOSet()
if using64bits:
class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
def setUp(self):
self.t = IIBTree()
def getTwoValues(self):
return 1, 2
class IFBTreeTest(BTreeTests, TestLongIntKeys):
class IFBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self):
self.t = IFBTree()
def getTwoValues(self):
return 0.5, 1.5
class IOBTreeTest(BTreeTests, TestLongIntKeys):
class IOBTreeTest(BTreeTests, TestLongIntKeys):
def setUp(self):
self.t = IOBTree()
class OIBTreeTest(BTreeTests, TestLongIntValues):
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 = 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):
def setUp(self):
self.t = OOBTree()
# cmp error propagation tests
class DoesntLikeBeingCompared:
......@@ -1651,22 +1650,12 @@ class TestCmpError(TestCase):
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 (
IIBTreeTest, IFBTreeTest, IOBTreeTest, OIBTreeTest,
LLBTreeTest, LFBTreeTest, LOBTreeTest, OLBTreeTest,
OOBTreeTest,
IIBucketTest, IIBTreeTest, IISetTest, IITreeSetTest,
IFBucketTest, IFBTreeTest, IFSetTest, IFTreeSetTest,
IOBucketTest, IOBTreeTest, IOSetTest, IOTreeSetTest,
OOBucketTest, OOBTreeTest, OOSetTest, OOTreeSetTest,
OIBucketTest, OIBTreeTest, OISetTest, OITreeSetTest,
# Note: there is no TestOOBTrees. The next three are
# checking for assorted TypeErrors, and when both keys
......@@ -1674,9 +1663,7 @@ def test_suite():
TestIIBTrees, TestIFBTrees, TestIOBTrees, TestOIBTrees,
TestIOSets,
DegenerateBTree,
TestCmpError,
BugFixes,
):
TestCmpError):
s.addTest(makeSuite(klass))
return s
......
......@@ -13,17 +13,12 @@
##############################################################################
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
......@@ -33,9 +28,6 @@ class Base:
storage = None
def setUp(self):
self.t = self.t_type()
def tearDown(self):
transaction.abort()
del self.t
......@@ -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)
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()
......@@ -762,19 +846,12 @@ class NastyConfict(Base, TestCase):
def test_suite():
suite = TestSuite()
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))
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))
return suite
......@@ -15,13 +15,8 @@ from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
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
......@@ -174,10 +169,6 @@ def makeBuilder(mapbuilder):
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)
......@@ -186,30 +177,14 @@ class PureIO(SetResult):
from BTrees.IOBTree import union, intersection, difference
builders = IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket)
class PureIF(SetResult):
from BTrees.IFBTree import union, intersection, difference
builders = IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket)
class PureOO(SetResult):
from BTrees.OOBTree import union, intersection, difference
builders = OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
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
......@@ -286,26 +261,6 @@ class TestIOMultiUnion(MultiUnion):
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):
......@@ -320,16 +275,6 @@ class TestImports(TestCase):
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:
......@@ -348,16 +293,6 @@ class TestImports(TestCase):
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:
......@@ -376,16 +311,6 @@ class TestImports(TestCase):
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:
......@@ -537,18 +462,6 @@ class TestWeightedOI(Weighted):
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.
......@@ -558,16 +471,10 @@ def isaset(thing):
def test_suite():
s = TestSuite()
for klass in (
TestIIMultiUnion, TestIOMultiUnion, TestIFMultiUnion,
TestLLMultiUnion, TestLOMultiUnion, TestLFMultiUnion,
for klass in (TestIIMultiUnion, TestIOMultiUnion,
TestImports,
PureOO,
PureII, PureIO, PureIF, PureOI,
PureLL, PureLO, PureLF, PureOL,
TestWeightedII, TestWeightedOI,
TestWeightedLL, TestWeightedOL,
):
PureII, PureIO, PureOI, PureOO,
TestWeightedII, TestWeightedOI):
s.addTest(makeSuite(klass))
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