Commit 4fd37b0d authored by Tres Seaver's avatar Tres Seaver

Test pure-Python II entities everywhere.

parent 03b23ae6
...@@ -35,6 +35,7 @@ that doesn't exist in the actual BTree). ...@@ -35,6 +35,7 @@ that doesn't exist in the actual BTree).
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
from BTrees.IFBTree import IFBTreePy, IFBucketPy, IFSetPy, IFTreeSetPy from BTrees.IFBTree import IFBTreePy, IFBucketPy, IFSetPy, IFTreeSetPy
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IIBTree import IIBTreePy, IIBucketPy, IISetPy, IITreeSetPy
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
......
...@@ -39,6 +39,13 @@ class IIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase): ...@@ -39,6 +39,13 @@ class IIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
from BTrees.IIBTree import IIBTree from BTrees.IIBTree import IIBTree
return IIBTree return IIBTree
class IIBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy
class IITreeSetInternalKeyTest(InternalKeysSetTest, unittest.TestCase): class IITreeSetInternalKeyTest(InternalKeysSetTest, unittest.TestCase):
...@@ -47,6 +54,13 @@ class IITreeSetInternalKeyTest(InternalKeysSetTest, unittest.TestCase): ...@@ -47,6 +54,13 @@ class IITreeSetInternalKeyTest(InternalKeysSetTest, unittest.TestCase):
return IITreeSet return IITreeSet
class IITreeSetPyInternalKeyTest(InternalKeysSetTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy
class IIBucketTest(MappingBase, unittest.TestCase): class IIBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -54,6 +68,13 @@ class IIBucketTest(MappingBase, unittest.TestCase): ...@@ -54,6 +68,13 @@ class IIBucketTest(MappingBase, unittest.TestCase):
return IIBucket return IIBucket
class IIBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucketPy
return IIBucketPy
class IITreeSetTest(NormalSetTests, unittest.TestCase): class IITreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -61,6 +82,13 @@ class IITreeSetTest(NormalSetTests, unittest.TestCase): ...@@ -61,6 +82,13 @@ class IITreeSetTest(NormalSetTests, unittest.TestCase):
return IITreeSet return IITreeSet
class IITreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy
class IISetTest(ExtendedSetTests, unittest.TestCase): class IISetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -68,11 +96,14 @@ class IISetTest(ExtendedSetTests, unittest.TestCase): ...@@ -68,11 +96,14 @@ class IISetTest(ExtendedSetTests, unittest.TestCase):
return IISet return IISet
class IIBTreeTest(BTreeTests, unittest.TestCase): class IISetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISetPy
return IISetPy
def _makeOne(self):
from BTrees.IIBTree import IIBTree class _IIBTreeTestBase(BTreeTests):
return IIBTree()
def testIIBTreeOverflow(self): def testIIBTreeOverflow(self):
good = set() good = set()
...@@ -97,22 +128,44 @@ class IIBTreeTest(BTreeTests, unittest.TestCase): ...@@ -97,22 +128,44 @@ class IIBTreeTest(BTreeTests, unittest.TestCase):
self.assertEqual(sorted(good), sorted(b)) self.assertEqual(sorted(good), sorted(b))
class IIBTreeTest(_IIBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IIBTree
return IIBTree()
class IIBTreeTestPy(_IIBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy()
if using64bits: if using64bits:
class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues, class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase): unittest.TestCase):
def _makeOne(self): def _makeOne(self):
from BTrees.IIBTree import IIBTree from BTrees.IIBTree import IIBTree
return IIBTree() return IIBTree()
def getTwoValues(self): def getTwoValues(self):
return 1, 2 return 1, 2
class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
class TestIIBTrees(unittest.TestCase): def _makeOne(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy()
def _makeOne(self): def getTwoValues(self):
from BTrees.IIBTree import IIBTree return 1, 2
return IIBTree()
class _TestIIBTreesBase(object):
def testNonIntegerKeyRaises(self): def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey) self.assertRaises(TypeError, self._stringraiseskey)
...@@ -143,6 +196,20 @@ class TestIIBTrees(unittest.TestCase): ...@@ -143,6 +196,20 @@ class TestIIBTrees(unittest.TestCase):
self._makeOne()[1] = None self._makeOne()[1] = None
class TestIIBTrees(_TestIIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IIBTree
return IIBTree()
class TestIIBTreesPy(_TestIIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy()
class TestIISets(I_SetsBase, unittest.TestCase): class TestIISets(I_SetsBase, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -150,6 +217,13 @@ class TestIISets(I_SetsBase, unittest.TestCase): ...@@ -150,6 +217,13 @@ class TestIISets(I_SetsBase, unittest.TestCase):
return IISet() return IISet()
class TestIISetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IISetPy
return IISetPy()
class TestIITreeSets(I_SetsBase, unittest.TestCase): class TestIITreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -157,16 +231,27 @@ class TestIITreeSets(I_SetsBase, unittest.TestCase): ...@@ -157,16 +231,27 @@ class TestIITreeSets(I_SetsBase, unittest.TestCase):
return IITreeSet() return IITreeSet()
class TestIITreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy()
class PureII(SetResult, unittest.TestCase): class PureII(SetResult, unittest.TestCase):
def union(self, *args): def union(self, *args):
from BTrees.IIBTree import union from BTrees.IIBTree import union
return union(*args) return union(*args)
def intersection(self, *args): def intersection(self, *args):
from BTrees.IIBTree import intersection from BTrees.IIBTree import intersection
return intersection(*args) return intersection(*args)
def difference(self, *args): def difference(self, *args):
from BTrees.IIBTree import difference from BTrees.IIBTree import difference
return difference(*args) return difference(*args)
def builders(self): def builders(self):
from BTrees.IIBTree import IIBTree from BTrees.IIBTree import IIBTree
from BTrees.IIBTree import IIBucket from BTrees.IIBTree import IIBucket
...@@ -175,42 +260,105 @@ class PureII(SetResult, unittest.TestCase): ...@@ -175,42 +260,105 @@ class PureII(SetResult, unittest.TestCase):
return IISet, IITreeSet, makeBuilder(IIBTree), makeBuilder(IIBucket) return IISet, IITreeSet, makeBuilder(IIBTree), makeBuilder(IIBucket)
class PureIIPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IIBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IIBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IIBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IIBTree import IIBTreePy
from BTrees.IIBTree import IIBucketPy
from BTrees.IIBTree import IITreeSetPy
from BTrees.IIBTree import IISetPy
return (IISetPy, IITreeSetPy,
makeBuilder(IIBTreePy), makeBuilder(IIBucketPy))
class TestIIMultiUnion(MultiUnion, unittest.TestCase): class TestIIMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args): def multiunion(self, *args):
from BTrees.IIBTree import multiunion from BTrees.IIBTree import multiunion
return multiunion(*args) return multiunion(*args)
def union(self, *args): def union(self, *args):
from BTrees.IIBTree import union from BTrees.IIBTree import union
return union(*args) return union(*args)
def mkset(self, *args): def mkset(self, *args):
from BTrees.IIBTree import IISet as mkset from BTrees.IIBTree import IISet as mkset
return mkset(*args) return mkset(*args)
def mktreeset(self, *args): def mktreeset(self, *args):
from BTrees.IIBTree import IITreeSet as mktreeset from BTrees.IIBTree import IITreeSet as mktreeset
return mktreeset(*args) return mktreeset(*args)
def mkbucket(self, *args): def mkbucket(self, *args):
from BTrees.IIBTree import IIBucket as mkbucket from BTrees.IIBTree import IIBucket as mkbucket
return mkbucket(*args) return mkbucket(*args)
def mkbtree(self, *args): def mkbtree(self, *args):
from BTrees.IIBTree import IIBTree as mkbtree from BTrees.IIBTree import IIBTree as mkbtree
return mkbtree(*args) return mkbtree(*args)
class TestIIMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IIBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IIBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IIBTree import IISetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IIBTree import IITreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IIBTree import IIBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IIBTree import IIBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedII(Weighted, unittest.TestCase): class TestWeightedII(Weighted, unittest.TestCase):
def weightedUnion(self): def weightedUnion(self):
from BTrees.IIBTree import weightedUnion from BTrees.IIBTree import weightedUnion
return weightedUnion return weightedUnion
def weightedIntersection(self): def weightedIntersection(self):
from BTrees.IIBTree import weightedIntersection from BTrees.IIBTree import weightedIntersection
return weightedIntersection return weightedIntersection
def union(self): def union(self):
from BTrees.IIBTree import union from BTrees.IIBTree import union
return union return union
def intersection(self): def intersection(self):
from BTrees.IIBTree import intersection from BTrees.IIBTree import intersection
return intersection return intersection
def mkbucket(self, *args): def mkbucket(self, *args):
from BTrees.IIBTree import IIBucket as mkbucket from BTrees.IIBTree import IIBucket as mkbucket
return mkbucket(*args) return mkbucket(*args)
def builders(self): def builders(self):
from BTrees.IIBTree import IIBTree from BTrees.IIBTree import IIBTree
from BTrees.IIBTree import IIBucket from BTrees.IIBTree import IIBucket
...@@ -219,6 +367,37 @@ class TestWeightedII(Weighted, unittest.TestCase): ...@@ -219,6 +367,37 @@ class TestWeightedII(Weighted, unittest.TestCase):
return IIBucket, IIBTree, itemsToSet(IISet), itemsToSet(IITreeSet) return IIBucket, IIBTree, itemsToSet(IISet), itemsToSet(IITreeSet)
class TestWeightedIIPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.IIBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.IIBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.IIBTree import unionPy
return unionPy
def intersection(self):
from BTrees.IIBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.IIBTree import IIBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.IIBTree import IIBTreePy
from BTrees.IIBTree import IIBucketPy
from BTrees.IIBTree import IITreeSetPy
from BTrees.IIBTree import IISetPy
return (IIBucketPy, IIBTreePy,
itemsToSet(IISetPy), itemsToSet(IITreeSetPy))
class IIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase): class IIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -226,6 +405,13 @@ class IIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase): ...@@ -226,6 +405,13 @@ class IIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
return IIBTree return IIBTree
class IIBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy
class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase): class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -233,6 +419,13 @@ class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase): ...@@ -233,6 +419,13 @@ class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
return IIBucket return IIBucket
class IIBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucketPy
return IIBucketPy
class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase): class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -240,6 +433,13 @@ class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase): ...@@ -240,6 +433,13 @@ class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
return IITreeSet return IITreeSet
class IITreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy
class IISetConflictTests(SetConflictTestBase, unittest.TestCase): class IISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -247,6 +447,13 @@ class IISetConflictTests(SetConflictTestBase, unittest.TestCase): ...@@ -247,6 +447,13 @@ class IISetConflictTests(SetConflictTestBase, unittest.TestCase):
return IISet return IISet
class IISetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISetPy
return IISetPy
class IIModuleTest(ModuleTest, unittest.TestCase): class IIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'II' prefix = 'II'
...@@ -263,20 +470,36 @@ class IIModuleTest(ModuleTest, unittest.TestCase): ...@@ -263,20 +470,36 @@ class IIModuleTest(ModuleTest, unittest.TestCase):
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(IIBTreeInternalKeyTest), unittest.makeSuite(IIBTreeInternalKeyTest),
unittest.makeSuite(IIBTreePyInternalKeyTest),
unittest.makeSuite(IITreeSetInternalKeyTest), unittest.makeSuite(IITreeSetInternalKeyTest),
unittest.makeSuite(IITreeSetPyInternalKeyTest),
unittest.makeSuite(IIBucketTest), unittest.makeSuite(IIBucketTest),
unittest.makeSuite(IIBucketPyTest),
unittest.makeSuite(IITreeSetTest), unittest.makeSuite(IITreeSetTest),
unittest.makeSuite(IITreeSetPyTest),
unittest.makeSuite(IISetTest), unittest.makeSuite(IISetTest),
unittest.makeSuite(IISetPyTest),
unittest.makeSuite(IIBTreeTest), unittest.makeSuite(IIBTreeTest),
unittest.makeSuite(IIBTreeTestPy),
unittest.makeSuite(TestIIBTrees), unittest.makeSuite(TestIIBTrees),
unittest.makeSuite(TestIIBTreesPy),
unittest.makeSuite(TestIISets), unittest.makeSuite(TestIISets),
unittest.makeSuite(TestIISetsPy),
unittest.makeSuite(TestIITreeSets), unittest.makeSuite(TestIITreeSets),
unittest.makeSuite(TestIITreeSetsPy),
unittest.makeSuite(TestIIMultiUnion), unittest.makeSuite(TestIIMultiUnion),
unittest.makeSuite(TestIIMultiUnionPy),
unittest.makeSuite(PureII), unittest.makeSuite(PureII),
unittest.makeSuite(PureIIPy),
unittest.makeSuite(TestWeightedII), unittest.makeSuite(TestWeightedII),
unittest.makeSuite(TestWeightedIIPy),
unittest.makeSuite(IIBTreeConflictTests), unittest.makeSuite(IIBTreeConflictTests),
unittest.makeSuite(IIBTreeConflictTestsPy),
unittest.makeSuite(IIBucketConflictTests), unittest.makeSuite(IIBucketConflictTests),
unittest.makeSuite(IIBucketConflictTestsPy),
unittest.makeSuite(IITreeSetConflictTests), unittest.makeSuite(IITreeSetConflictTests),
unittest.makeSuite(IITreeSetConflictTestsPy),
unittest.makeSuite(IISetConflictTests), unittest.makeSuite(IISetConflictTests),
unittest.makeSuite(IISetConflictTestsPy),
unittest.makeSuite(IIModuleTest), unittest.makeSuite(IIModuleTest),
)) ))
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