Commit ad13669b authored by Tres Seaver's avatar Tres Seaver

Move type-specific conflict tests into per-type testcase modules.

parent cc42ae55
...@@ -1853,6 +1853,291 @@ class MultiUnion(object): ...@@ -1853,6 +1853,291 @@ class MultiUnion(object):
self.assertEqual(list(fast), range(N)) self.assertEqual(list(fast), range(N))
class ConflictTestBase(object):
# Tests common to all types: sets, buckets, and BTrees
storage = None
def tearDown(self):
import transaction
transaction.abort()
if self.storage is not None:
self.storage.close()
self.storage.cleanup()
def _makeOne(self):
return self._getTargetClass()()
def openDB(self):
import os
from ZODB.FileStorage import FileStorage
from ZODB.DB import DB
n = 'fs_tmp__%s' % os.getpid()
self.storage = FileStorage(n)
self.db = DB(self.storage)
return self.db
def _test_merge(o1, o2, o3, expect, message='failed to merge', should_fail=0):
from BTrees.Interfaces import BTreesConflictError
s1 = o1.__getstate__()
s2 = o2.__getstate__()
s3 = o3.__getstate__()
expected = expect.__getstate__()
if expected is None:
expected = ((((),),),)
if should_fail:
try:
merged = o1._p_resolveConflict(s1, s2, s3)
except BTreesConflictError, err:
pass
else:
assert 0, message
else:
merged = o1._p_resolveConflict(s1, s2, s3)
assert merged == expected, message
class MappingConflictTestBase(ConflictTestBase):
# Tests common to mappings (buckets, btrees).
def _deletefail(self):
t = self._makeOne()
del t[1]
def _setupConflict(self):
l=[ -5124, -7377, 2274, 8801, -9901, 7327, 1565, 17, -679,
3686, -3607, 14, 6419, -5637, 6040, -4556, -8622, 3847, 7191,
-4067]
e1=[(-1704, 0), (5420, 1), (-239, 2), (4024, 3), (-6984, 4)]
e2=[(7745, 0), (4868, 1), (-2548, 2), (-2711, 3), (-3154, 4)]
base = self._makeOne()
base.update([(i, i*i) for i in l[:20]])
b1=base.__class__(base)
b2=base.__class__(base)
bm=base.__class__(base)
items=base.items()
return base, b1, b2, bm, e1, e2, items
def testMergeDelete(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
del b1[items[1][0]]
del b2[items[5][0]]
del b1[items[-1][0]]
del b2[items[-2][0]]
del bm[items[1][0]]
del bm[items[5][0]]
del bm[items[-1][0]]
del bm[items[-2][0]]
_test_merge(base, b1, b2, bm, 'merge delete')
def testMergeDeleteAndUpdate(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
del b1[items[1][0]]
b2[items[5][0]]=1
del b1[items[-1][0]]
b2[items[-2][0]]=2
del bm[items[1][0]]
bm[items[5][0]]=1
del bm[items[-1][0]]
bm[items[-2][0]]=2
_test_merge(base, b1, b2, bm, 'merge update and delete')
def testMergeUpdate(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1[items[0][0]]=1
b2[items[5][0]]=2
b1[items[-1][0]]=3
b2[items[-2][0]]=4
bm[items[0][0]]=1
bm[items[5][0]]=2
bm[items[-1][0]]=3
bm[items[-2][0]]=4
_test_merge(base, b1, b2, bm, 'merge update')
def testFailMergeDelete(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
del b1[items[0][0]]
del b2[items[0][0]]
_test_merge(base, b1, b2, bm, 'merge conflicting delete',
should_fail=1)
def testFailMergeUpdate(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1[items[0][0]]=1
b2[items[0][0]]=2
_test_merge(base, b1, b2, bm, 'merge conflicting update',
should_fail=1)
def testFailMergeDeleteAndUpdate(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
del b1[items[0][0]]
b2[items[0][0]]=-9
_test_merge(base, b1, b2, bm, 'merge conflicting update and delete',
should_fail=1)
def testMergeInserts(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1[-99999]=-99999
b1[e1[0][0]]=e1[0][1]
b2[99999]=99999
b2[e1[2][0]]=e1[2][1]
bm[-99999]=-99999
bm[e1[0][0]]=e1[0][1]
bm[99999]=99999
bm[e1[2][0]]=e1[2][1]
_test_merge(base, b1, b2, bm, 'merge insert')
def testMergeInsertsFromEmpty(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
base.clear()
b1.clear()
b2.clear()
bm.clear()
b1.update(e1)
bm.update(e1)
b2.update(e2)
bm.update(e2)
_test_merge(base, b1, b2, bm, 'merge insert from empty')
def testFailMergeEmptyAndFill(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.clear()
bm.clear()
b2.update(e2)
bm.update(e2)
_test_merge(base, b1, b2, bm, 'merge insert from empty', should_fail=1)
def testMergeEmpty(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.clear()
bm.clear()
_test_merge(base, b1, b2, bm, 'empty one and not other', should_fail=1)
def testFailMergeInsert(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1[-99999]=-99999
b1[e1[0][0]]=e1[0][1]
b2[99999]=99999
b2[e1[0][0]]=e1[0][1]
_test_merge(base, b1, b2, bm, 'merge conflicting inserts',
should_fail=1)
class SetConflictTestBase(ConflictTestBase):
"Set (as opposed to TreeSet) specific tests."
def _setupConflict(self):
l=[ -5124, -7377, 2274, 8801, -9901, 7327, 1565, 17, -679,
3686, -3607, 14, 6419, -5637, 6040, -4556, -8622, 3847, 7191,
-4067]
e1=[-1704, 5420, -239, 4024, -6984]
e2=[7745, 4868, -2548, -2711, -3154]
base = self._makeOne()
base.update(l)
b1=base.__class__(base)
b2=base.__class__(base)
bm=base.__class__(base)
items=base.keys()
return base, b1, b2, bm, e1, e2, items
def testMergeDelete(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.remove(items[1])
b2.remove(items[5])
b1.remove(items[-1])
b2.remove(items[-2])
bm.remove(items[1])
bm.remove(items[5])
bm.remove(items[-1])
bm.remove(items[-2])
_test_merge(base, b1, b2, bm, 'merge delete')
def testFailMergeDelete(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.remove(items[0])
b2.remove(items[0])
_test_merge(base, b1, b2, bm, 'merge conflicting delete',
should_fail=1)
def testMergeInserts(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.insert(-99999)
b1.insert(e1[0])
b2.insert(99999)
b2.insert(e1[2])
bm.insert(-99999)
bm.insert(e1[0])
bm.insert(99999)
bm.insert(e1[2])
_test_merge(base, b1, b2, bm, 'merge insert')
def testMergeInsertsFromEmpty(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
base.clear()
b1.clear()
b2.clear()
bm.clear()
b1.update(e1)
bm.update(e1)
b2.update(e2)
bm.update(e2)
_test_merge(base, b1, b2, bm, 'merge insert from empty')
def testFailMergeEmptyAndFill(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.clear()
bm.clear()
b2.update(e2)
bm.update(e2)
_test_merge(base, b1, b2, bm, 'merge insert from empty', should_fail=1)
def testMergeEmpty(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.clear()
bm.clear()
_test_merge(base, b1, b2, bm, 'empty one and not other', should_fail=1)
def testFailMergeInsert(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
b1.insert(-99999)
b1.insert(e1[0])
b2.insert(99999)
b2.insert(e1[0])
_test_merge(base, b1, b2, bm, 'merge conflicting inserts',
should_fail=1)
## utility functions ## utility functions
def lsubtract(l1, l2): def lsubtract(l1, l2):
......
This diff is collapsed.
...@@ -18,9 +18,11 @@ from .common import ExtendedSetTests ...@@ -18,9 +18,11 @@ from .common import ExtendedSetTests
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntKeys from .common import TestLongIntKeys
from .common import makeBuilder from .common import makeBuilder
...@@ -60,18 +62,6 @@ class IFSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -60,18 +62,6 @@ class IFSetTest(ExtendedSetTests, unittest.TestCase):
from BTrees.IFBTree import IFSet from BTrees.IFBTree import IFSet
return IFSet return IFSet
class IFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IF'
def _getModule(self):
import BTrees
return BTrees.IFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerFloatBTreeModule
class IFBTreeTest(BTreeTests, unittest.TestCase): class IFBTreeTest(BTreeTests, unittest.TestCase):
...@@ -161,6 +151,47 @@ class PureIF(SetResult, unittest.TestCase): ...@@ -161,6 +151,47 @@ class PureIF(SetResult, unittest.TestCase):
from BTrees.IFBTree import IFSet from BTrees.IFBTree import IFSet
return IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket) return IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket)
class IFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTree
return IFBTree
class IFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucket
return IFBucket
class IFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSet
return IFTreeSet
class IFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSet
return IFSet
class IFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IF'
def _getModule(self):
import BTrees
return BTrees.IFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerFloatBTreeModule
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(IFBTreeInternalKeyTest), unittest.makeSuite(IFBTreeInternalKeyTest),
...@@ -171,7 +202,10 @@ def test_suite(): ...@@ -171,7 +202,10 @@ def test_suite():
unittest.makeSuite(IFModuleTest), unittest.makeSuite(IFModuleTest),
unittest.makeSuite(IFBTreeTest), unittest.makeSuite(IFBTreeTest),
unittest.makeSuite(TestIFBTrees), unittest.makeSuite(TestIFBTrees),
unittest.makeSuite(TestIFMultiUnion), unittest.makeSuite(TestIFMultiUnion),
unittest.makeSuite(PureIF), unittest.makeSuite(PureIF),
unittest.makeSuite(IFBTreeConflictTests),
unittest.makeSuite(IFBucketConflictTests),
unittest.makeSuite(IFTreeSetConflictTests),
unittest.makeSuite(IFSetConflictTests),
)) ))
...@@ -19,9 +19,11 @@ from .common import I_SetsBase ...@@ -19,9 +19,11 @@ from .common import I_SetsBase
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntKeys from .common import TestLongIntKeys
from .common import TestLongIntValues from .common import TestLongIntValues
...@@ -66,18 +68,6 @@ class IISetTest(ExtendedSetTests, unittest.TestCase): ...@@ -66,18 +68,6 @@ class IISetTest(ExtendedSetTests, unittest.TestCase):
return IISet return IISet
class IIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'II'
def _getModule(self):
import BTrees
return BTrees.IIBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerIntegerBTreeModule
class IIBTreeTest(BTreeTests, unittest.TestCase): class IIBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -229,6 +219,46 @@ class TestWeightedII(Weighted, unittest.TestCase): ...@@ -229,6 +219,46 @@ class TestWeightedII(Weighted, unittest.TestCase):
return IIBucket, IIBTree, itemsToSet(IISet), itemsToSet(IITreeSet) return IIBucket, IIBTree, itemsToSet(IISet), itemsToSet(IITreeSet)
class IIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTree
return IIBTree
class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucket
return IIBucket
class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSet
return IITreeSet
class IISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISet
return IISet
class IIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'II'
def _getModule(self):
import BTrees
return BTrees.IIBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerIntegerBTreeModule
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
...@@ -237,7 +267,6 @@ def test_suite(): ...@@ -237,7 +267,6 @@ def test_suite():
unittest.makeSuite(IIBucketTest), unittest.makeSuite(IIBucketTest),
unittest.makeSuite(IITreeSetTest), unittest.makeSuite(IITreeSetTest),
unittest.makeSuite(IISetTest), unittest.makeSuite(IISetTest),
unittest.makeSuite(IIModuleTest),
unittest.makeSuite(IIBTreeTest), unittest.makeSuite(IIBTreeTest),
unittest.makeSuite(TestIIBTrees), unittest.makeSuite(TestIIBTrees),
unittest.makeSuite(TestIISets), unittest.makeSuite(TestIISets),
...@@ -245,4 +274,9 @@ def test_suite(): ...@@ -245,4 +274,9 @@ def test_suite():
unittest.makeSuite(TestIIMultiUnion), unittest.makeSuite(TestIIMultiUnion),
unittest.makeSuite(PureII), unittest.makeSuite(PureII),
unittest.makeSuite(TestWeightedII), unittest.makeSuite(TestWeightedII),
unittest.makeSuite(IIBTreeConflictTests),
unittest.makeSuite(IIBucketConflictTests),
unittest.makeSuite(IITreeSetConflictTests),
unittest.makeSuite(IISetConflictTests),
unittest.makeSuite(IIModuleTest),
)) ))
...@@ -19,9 +19,11 @@ from .common import I_SetsBase ...@@ -19,9 +19,11 @@ from .common import I_SetsBase
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TypeTest from .common import TypeTest
from .common import TestLongIntKeys from .common import TestLongIntKeys
...@@ -64,35 +66,6 @@ class IOSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -64,35 +66,6 @@ class IOSetTest(ExtendedSetTests, unittest.TestCase):
return IOSet return IOSet
class IOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IO'
def _getModule(self):
import BTrees
return BTrees.IOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.IOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.IOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedIntersection")
class IOBTreeTest(BTreeTests, unittest.TestCase): class IOBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -174,6 +147,63 @@ class TestIOMultiUnion(MultiUnion, unittest.TestCase): ...@@ -174,6 +147,63 @@ class TestIOMultiUnion(MultiUnion, unittest.TestCase):
return mkbtree(*args) return mkbtree(*args)
class IOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTree
return IOBTree
class IOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucket
return IOBucket
class IOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet
class IOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSet
return IOSet
class IOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IO'
def _getModule(self):
import BTrees
return BTrees.IOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.IOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.IOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedIntersection")
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(IOBTreeInternalKeyTest), unittest.makeSuite(IOBTreeInternalKeyTest),
...@@ -181,11 +211,15 @@ def test_suite(): ...@@ -181,11 +211,15 @@ def test_suite():
unittest.makeSuite(IOBucketTest), unittest.makeSuite(IOBucketTest),
unittest.makeSuite(IOTreeSetTest), unittest.makeSuite(IOTreeSetTest),
unittest.makeSuite(IOSetTest), unittest.makeSuite(IOSetTest),
unittest.makeSuite(IOModuleTest),
unittest.makeSuite(IOBTreeTest), unittest.makeSuite(IOBTreeTest),
unittest.makeSuite(TestIOBTrees), unittest.makeSuite(TestIOBTrees),
unittest.makeSuite(TestIOSets), unittest.makeSuite(TestIOSets),
unittest.makeSuite(TestIOTreeSets), unittest.makeSuite(TestIOTreeSets),
unittest.makeSuite(TestIOMultiUnion), unittest.makeSuite(TestIOMultiUnion),
unittest.makeSuite(PureIO), unittest.makeSuite(PureIO),
unittest.makeSuite(IOBTreeConflictTests),
unittest.makeSuite(IOBucketConflictTests),
unittest.makeSuite(IOTreeSetConflictTests),
unittest.makeSuite(IOSetConflictTests),
unittest.makeSuite(IOModuleTest),
)) ))
...@@ -18,9 +18,11 @@ from .common import ExtendedSetTests ...@@ -18,9 +18,11 @@ from .common import ExtendedSetTests
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntKeys from .common import TestLongIntKeys
from .common import makeBuilder from .common import makeBuilder
...@@ -61,19 +63,6 @@ class LFSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -61,19 +63,6 @@ class LFSetTest(ExtendedSetTests, unittest.TestCase):
return LFSet return LFSet
class LFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LF'
def _getModule(self):
import BTrees
return BTrees.LFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerFloatBTreeModule
class LFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase): class LFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -123,6 +112,47 @@ class PureLF(SetResult, unittest.TestCase): ...@@ -123,6 +112,47 @@ class PureLF(SetResult, unittest.TestCase):
return LFSet, LFTreeSet, makeBuilder(LFBTree), makeBuilder(LFBucket) return LFSet, LFTreeSet, makeBuilder(LFBTree), makeBuilder(LFBucket)
class LFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBTree
return LFBTree
class LFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBucket
return LFBucket
class LFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFTreeSet
return LFTreeSet
class LFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFSet
return LFSet
class LFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LF'
def _getModule(self):
import BTrees
return BTrees.LFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerFloatBTreeModule
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(LFBTreeInternalKeyTest), unittest.makeSuite(LFBTreeInternalKeyTest),
...@@ -130,9 +160,12 @@ def test_suite(): ...@@ -130,9 +160,12 @@ def test_suite():
unittest.makeSuite(LFBucketTest), unittest.makeSuite(LFBucketTest),
unittest.makeSuite(LFTreeSetTest), unittest.makeSuite(LFTreeSetTest),
unittest.makeSuite(LFSetTest), unittest.makeSuite(LFSetTest),
unittest.makeSuite(LFModuleTest),
unittest.makeSuite(LFBTreeTest), unittest.makeSuite(LFBTreeTest),
unittest.makeSuite(TestLFMultiUnion), unittest.makeSuite(TestLFMultiUnion),
unittest.makeSuite(PureLF), unittest.makeSuite(PureLF),
unittest.makeSuite(LFBTreeConflictTests),
unittest.makeSuite(LFBucketConflictTests),
unittest.makeSuite(LFTreeSetConflictTests),
unittest.makeSuite(LFSetConflictTests),
unittest.makeSuite(LFModuleTest),
)) ))
...@@ -19,9 +19,11 @@ from .common import I_SetsBase ...@@ -19,9 +19,11 @@ from .common import I_SetsBase
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntKeys from .common import TestLongIntKeys
from .common import TestLongIntValues from .common import TestLongIntValues
...@@ -72,19 +74,6 @@ class LLSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -72,19 +74,6 @@ class LLSetTest(ExtendedSetTests, unittest.TestCase):
return LLSet return LLSet
class LLModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LL'
def _getModule(self):
import BTrees
return BTrees.LLBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerIntegerBTreeModule
class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues, class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase): unittest.TestCase):
...@@ -172,6 +161,47 @@ class TestWeightedLL(Weighted, unittest.TestCase): ...@@ -172,6 +161,47 @@ class TestWeightedLL(Weighted, unittest.TestCase):
return LLBucket, LLBTree, itemsToSet(LLSet), itemsToSet(LLTreeSet) return LLBucket, LLBTree, itemsToSet(LLSet), itemsToSet(LLTreeSet)
class LLBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBTree
return LLBTree
class LLBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBucket
return LLBucket
class LLTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLTreeSet
return LLTreeSet
class LLSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLSet
return LLSet
class LLModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LL'
def _getModule(self):
import BTrees
return BTrees.LLBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerIntegerBTreeModule
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(LLBTreeInternalKeyTest), unittest.makeSuite(LLBTreeInternalKeyTest),
...@@ -183,8 +213,11 @@ def test_suite(): ...@@ -183,8 +213,11 @@ def test_suite():
unittest.makeSuite(LLBTreeTest), unittest.makeSuite(LLBTreeTest),
unittest.makeSuite(TestLLSets), unittest.makeSuite(TestLLSets),
unittest.makeSuite(TestLLTreeSets), unittest.makeSuite(TestLLTreeSets),
unittest.makeSuite(TestLLMultiUnion), unittest.makeSuite(TestLLMultiUnion),
unittest.makeSuite(PureLL), unittest.makeSuite(PureLL),
unittest.makeSuite(TestWeightedLL), unittest.makeSuite(TestWeightedLL),
unittest.makeSuite(LLBTreeConflictTests),
unittest.makeSuite(LLBucketConflictTests),
unittest.makeSuite(LLTreeSetConflictTests),
unittest.makeSuite(LLSetConflictTests),
)) ))
...@@ -19,9 +19,11 @@ from .common import I_SetsBase ...@@ -19,9 +19,11 @@ from .common import I_SetsBase
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import MultiUnion from .common import MultiUnion
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntKeys from .common import TestLongIntKeys
from .common import makeBuilder from .common import makeBuilder
...@@ -62,35 +64,6 @@ class LOSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -62,35 +64,6 @@ class LOSetTest(ExtendedSetTests, unittest.TestCase):
return LOSet return LOSet
class LOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LO'
def _getModule(self):
import BTrees
return BTrees.LOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.LOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("LOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.LOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("LOBTree shouldn't have weightedIntersection")
class LOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase): class LOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
...@@ -152,6 +125,63 @@ class PureLO(SetResult, unittest.TestCase): ...@@ -152,6 +125,63 @@ class PureLO(SetResult, unittest.TestCase):
return LOSet, LOTreeSet, makeBuilder(LOBTree), makeBuilder(LOBucket) return LOSet, LOTreeSet, makeBuilder(LOBTree), makeBuilder(LOBucket)
class LOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBTree
return LOBTree
class LOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBucket
return LOBucket
class LOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOTreeSet
return LOTreeSet
class LOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOSet
return LOSet
class LOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LO'
def _getModule(self):
import BTrees
return BTrees.LOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.LOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("LOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.LOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("LOBTree shouldn't have weightedIntersection")
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(LOBTreeInternalKeyTest), unittest.makeSuite(LOBTreeInternalKeyTest),
...@@ -159,11 +189,14 @@ def test_suite(): ...@@ -159,11 +189,14 @@ def test_suite():
unittest.makeSuite(LOBucketTest), unittest.makeSuite(LOBucketTest),
unittest.makeSuite(LOTreeSetTest), unittest.makeSuite(LOTreeSetTest),
unittest.makeSuite(LOSetTest), unittest.makeSuite(LOSetTest),
unittest.makeSuite(LOModuleTest),
unittest.makeSuite(LOBTreeTest), unittest.makeSuite(LOBTreeTest),
unittest.makeSuite(TestLOSets), unittest.makeSuite(TestLOSets),
unittest.makeSuite(TestLOTreeSets), unittest.makeSuite(TestLOTreeSets),
unittest.makeSuite(TestLOMultiUnion), unittest.makeSuite(TestLOMultiUnion),
unittest.makeSuite(PureLO), unittest.makeSuite(PureLO),
unittest.makeSuite(LOBTreeConflictTests),
unittest.makeSuite(LOBucketConflictTests),
unittest.makeSuite(LOTreeSetConflictTests),
unittest.makeSuite(LOSetConflictTests),
unittest.makeSuite(LOModuleTest),
)) ))
...@@ -18,8 +18,10 @@ from .common import ExtendedSetTests ...@@ -18,8 +18,10 @@ from .common import ExtendedSetTests
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntValues from .common import TestLongIntValues
from .common import TypeTest from .common import TypeTest
...@@ -64,27 +66,6 @@ class OISetTest(ExtendedSetTests, unittest.TestCase): ...@@ -64,27 +66,6 @@ class OISetTest(ExtendedSetTests, unittest.TestCase):
return OISet return OISet
class OIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OI'
def _getModule(self):
import BTrees
return BTrees.OIBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectIntegerBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OIBTree import multiunion
except ImportError:
pass
else:
self.fail("OIBTree shouldn't have multiunion")
class OIBTreeTest(BTreeTests, unittest.TestCase): class OIBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -174,6 +155,55 @@ class TestWeightedOI(Weighted, unittest.TestCase): ...@@ -174,6 +155,55 @@ class TestWeightedOI(Weighted, unittest.TestCase):
return OIBucket, OIBTree, itemsToSet(OISet), itemsToSet(OITreeSet) return OIBucket, OIBTree, itemsToSet(OISet), itemsToSet(OITreeSet)
class OIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBucket
return OIBucket
class OISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OISet
return OISet
class OIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBTree
return OIBTree
class OITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OITreeSet
return OITreeSet
class OIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OI'
def _getModule(self):
import BTrees
return BTrees.OIBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectIntegerBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OIBTree import multiunion
except ImportError:
pass
else:
self.fail("OIBTree shouldn't have multiunion")
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(OIBTreeInternalKeyTest), unittest.makeSuite(OIBTreeInternalKeyTest),
...@@ -181,10 +211,13 @@ def test_suite(): ...@@ -181,10 +211,13 @@ def test_suite():
unittest.makeSuite(OIBucketTest), unittest.makeSuite(OIBucketTest),
unittest.makeSuite(OITreeSetTest), unittest.makeSuite(OITreeSetTest),
unittest.makeSuite(OISetTest), unittest.makeSuite(OISetTest),
unittest.makeSuite(OIModuleTest),
unittest.makeSuite(OIBTreeTest), unittest.makeSuite(OIBTreeTest),
unittest.makeSuite(TestOIBTrees), unittest.makeSuite(TestOIBTrees),
unittest.makeSuite(PureOI), unittest.makeSuite(PureOI),
unittest.makeSuite(TestWeightedOI), unittest.makeSuite(TestWeightedOI),
unittest.makeSuite(OIBucketConflictTests),
unittest.makeSuite(OISetConflictTests),
unittest.makeSuite(OIBTreeConflictTests),
unittest.makeSuite(OITreeSetConflictTests),
unittest.makeSuite(OIModuleTest),
)) ))
...@@ -18,8 +18,10 @@ from .common import ExtendedSetTests ...@@ -18,8 +18,10 @@ from .common import ExtendedSetTests
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult from .common import SetResult
from .common import TestLongIntValues from .common import TestLongIntValues
from .common import Weighted from .common import Weighted
...@@ -62,27 +64,6 @@ class OLSetTest(ExtendedSetTests, unittest.TestCase): ...@@ -62,27 +64,6 @@ class OLSetTest(ExtendedSetTests, unittest.TestCase):
return OLSet return OLSet
class OLModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OL'
def _getModule(self):
import BTrees
return BTrees.OLBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectIntegerBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OLBTree import multiunion
except ImportError:
pass
else:
self.fail("OLBTree shouldn't have multiunion")
class OLBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase): class OLBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self): def _makeOne(self):
...@@ -135,6 +116,55 @@ class TestWeightedOL(Weighted, unittest.TestCase): ...@@ -135,6 +116,55 @@ class TestWeightedOL(Weighted, unittest.TestCase):
return OLBucket, OLBTree, itemsToSet(OLSet), itemsToSet(OLTreeSet) return OLBucket, OLBTree, itemsToSet(OLSet), itemsToSet(OLTreeSet)
class OLBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBucket
return OLBucket
class OLSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLSet
return OLSet
class OLBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBTree
return OLBTree
class OLTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLTreeSet
return OLTreeSet
class OLModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OL'
def _getModule(self):
import BTrees
return BTrees.OLBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectIntegerBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OLBTree import multiunion
except ImportError:
pass
else:
self.fail("OLBTree shouldn't have multiunion")
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(OLBTreeInternalKeyTest), unittest.makeSuite(OLBTreeInternalKeyTest),
...@@ -142,9 +172,12 @@ def test_suite(): ...@@ -142,9 +172,12 @@ def test_suite():
unittest.makeSuite(OLBucketTest), unittest.makeSuite(OLBucketTest),
unittest.makeSuite(OLTreeSetTest), unittest.makeSuite(OLTreeSetTest),
unittest.makeSuite(OLSetTest), unittest.makeSuite(OLSetTest),
unittest.makeSuite(OLModuleTest),
unittest.makeSuite(OLBTreeTest), unittest.makeSuite(OLBTreeTest),
unittest.makeSuite(PureOL), unittest.makeSuite(PureOL),
unittest.makeSuite(TestWeightedOL), unittest.makeSuite(TestWeightedOL),
unittest.makeSuite(OLBucketConflictTests),
unittest.makeSuite(OLSetConflictTests),
unittest.makeSuite(OLBTreeConflictTests),
unittest.makeSuite(OLTreeSetConflictTests),
unittest.makeSuite(OLModuleTest),
)) ))
...@@ -18,12 +18,15 @@ from .common import ExtendedSetTests ...@@ -18,12 +18,15 @@ from .common import ExtendedSetTests
from .common import InternalKeysMappingTest from .common import InternalKeysMappingTest
from .common import InternalKeysSetTest from .common import InternalKeysSetTest
from .common import MappingBase from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest from .common import ModuleTest
from .common import NormalSetTests from .common import NormalSetTests
from .common import SetResult from .common import SetResult
from .common import SetConflictTestBase
from .common import makeBuilder from .common import makeBuilder
class OOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase): class OOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
...@@ -192,6 +195,34 @@ class PureOOPy(SetResult, unittest.TestCase): ...@@ -192,6 +195,34 @@ class PureOOPy(SetResult, unittest.TestCase):
makeBuilder(OOBTreePy), makeBuilder(OOBucketPy)) makeBuilder(OOBTreePy), makeBuilder(OOBucketPy))
class OOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBucket
return OOBucket
class OOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOSet
return OOSet
class OOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBTree
return OOBTree
class OOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOTreeSet
return OOTreeSet
class OOModuleTest(ModuleTest, unittest.TestCase): class OOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OO' prefix = 'OO'
...@@ -245,5 +276,9 @@ def test_suite(): ...@@ -245,5 +276,9 @@ def test_suite():
unittest.makeSuite(OOBTreePyTest), unittest.makeSuite(OOBTreePyTest),
unittest.makeSuite(PureOO), unittest.makeSuite(PureOO),
unittest.makeSuite(PureOOPy), unittest.makeSuite(PureOOPy),
unittest.makeSuite(OOBucketConflictTests),
unittest.makeSuite(OOSetConflictTests),
unittest.makeSuite(OOBTreeConflictTests),
unittest.makeSuite(OOTreeSetConflictTests),
unittest.makeSuite(OOModuleTest), unittest.makeSuite(OOModuleTest),
)) ))
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