Skip to content

Commit

Permalink
The value of using64bits was broken in OIBTree with pure python.
Browse files Browse the repository at this point in the history
Fix it.

Also it's possible to statically know the expected value of using64bits for all included tree modules, so we don't need the (unexecuted) branch that creates (unused) test code in the *I* test modules.
  • Loading branch information
jamadden committed Feb 17, 2020
1 parent 03eafc7 commit f3b7be2
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 223 deletions.
2 changes: 1 addition & 1 deletion BTrees/OIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
using64bits = False

class OIBucketPy(Bucket):
_to_key = _to_key
Expand Down
23 changes: 1 addition & 22 deletions BTrees/tests/test_IFBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import makeBuilder
from BTrees.IIBTree import using64bits #XXX Ugly, but unavoidable



class IFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -97,26 +96,6 @@ def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()

if using64bits:

class IFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.IFBTree import IFBTree
return IFBTree()

def getTwoValues(self):
return 0.5, 1.5

class IFBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()

def getTwoValues(self):
return 0.5, 1.5


class _TestIFBTreesBase(object):

Expand Down
27 changes: 1 addition & 26 deletions BTrees/tests/test_IIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from BTrees.IIBTree import using64bits #XXX Ugly, but unavoidable



class IIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -130,29 +128,6 @@ def _makeOne(self):
return IIBTreePy()


if using64bits:

class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.IIBTree import IIBTree
return IIBTree()

def getTwoValues(self):
return 1, 2

class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy()

def getTwoValues(self):
return 1, 2


class _TestIIBTreesBase(object):

def testNonIntegerKeyRaises(self):
Expand Down
20 changes: 1 addition & 19 deletions BTrees/tests/test_IOBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
from .common import SetConflictTestBase
from .common import SetResult
from .common import TypeTest
from .common import TestLongIntKeys
from .common import makeBuilder
from BTrees.IIBTree import using64bits #XXX Ugly, but unavoidable



class IOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -100,23 +99,6 @@ def _makeOne(self):
return IOBTreePy()


if using64bits:


class IOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.IOBTree import IOBTree
return IOBTree()


class IOBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy()


class _TestIOBTreesBase(TypeTest):

def _stringraises(self):
Expand Down
27 changes: 1 addition & 26 deletions BTrees/tests/test_IUBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import UnsignedValuesMixin
from .common import UnsignedError
from BTrees.IUBTree import using64bits # XXX Ugly, but unavoidable


# pylint:disable=no-name-in-module,arguments-differ

Expand Down Expand Up @@ -130,29 +128,6 @@ def _makeOne(self):
return IUBTreePy()


if using64bits:

class IUBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.IUBTree import IUBTree
return IUBTree()

def getTwoValues(self):
return 1, 2

class IUBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.IUBTree import IUBTreePy
return IUBTreePy()

def getTwoValues(self):
return 1, 2


class _TestIUBTreesBase(object):

def testNonIntegerKeyRaises(self):
Expand Down
20 changes: 1 addition & 19 deletions BTrees/tests/test_OIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntValues
from .common import TypeTest
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from BTrees.OIBTree import using64bits #XXX Ugly, but necessary



class OIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -99,23 +98,6 @@ def _makeOne(self):
return OIBTreePy()


if using64bits:

class OIBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTree
return OIBTree()
def getTwoKeys(self):
return object(), object()

class OIBTreePyTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTreePy
return OIBTreePy()
def getTwoKeys(self):
return object(), object()


class _TestOIBTreesBase(TypeTest):

def _stringraises(self):
Expand Down
18 changes: 0 additions & 18 deletions BTrees/tests/test_OUBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from .common import itemsToSet
from .common import makeBuilder
from .common import UnsignedValuesMixin
from BTrees.IIBTree import using64bits #XXX Ugly, but necessary


class OUBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -101,23 +100,6 @@ def _makeOne(self):
return OUBTreePy()


if using64bits:

class OUBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTree
return OUBTree()
def getTwoKeys(self):
return object(), object()

class OUBTreePyTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTreePy
return OUBTreePy()
def getTwoKeys(self):
return object(), object()


class _TestOUBTreesBase(TypeTest):

def _stringraises(self):
Expand Down
23 changes: 1 addition & 22 deletions BTrees/tests/test_UFBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
from .common import UnsignedNormalSetTests as NormalSetTests
from .common import UnsignedSetConflictTestBase as SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import makeBuilder
from .common import UnsignedKeysMixin
from BTrees.IIBTree import using64bits #XXX Ugly, but unavoidable


# pylint:disable=no-name-in-module,arguments-differ

Expand Down Expand Up @@ -99,26 +98,6 @@ def _makeOne(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy()

if using64bits:

class UFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.UFBTree import UFBTree
return UFBTree()

def getTwoValues(self):
return 0.5, 1.5

class UFBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy()

def getTwoValues(self):
return 0.5, 1.5


class _TestUFBTreesBase(object):

Expand Down
27 changes: 1 addition & 26 deletions BTrees/tests/test_UIBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
from .common import UnsignedNormalSetTests as NormalSetTests
from .common import UnsignedSetConflictTestBase as SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import UnsignedKeysMixin
from .common import UnsignedError
from BTrees.UIBTree import using64bits #XXX Ugly, but unavoidable



# pylint:disable=no-name-in-module,arguments-differ
Expand Down Expand Up @@ -138,29 +136,6 @@ def _makeOne(self):
return UIBTreePy()


if using64bits:

class UIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.UIBTree import UIBTree
return UIBTree()

def getTwoValues(self):
return 1, 2

class UIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.UIBTree import UIBTreePy
return UIBTreePy()

def getTwoValues(self):
return 1, 2


class _TestUIBTreesBase(object):

def testNonIntegerKeyRaises(self):
Expand Down
19 changes: 1 addition & 18 deletions BTrees/tests/test_UOBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .common import makeBuilder
from .common import UnsignedKeysMixin
from .common import UnsignedError
from BTrees.UOBTree import using64bits #XXX Ugly, but unavoidable


# pylint:disable=no-name-in-module,arguments-differ

Expand Down Expand Up @@ -103,23 +103,6 @@ def _makeOne(self):
return UOBTreePy()


if using64bits:


class UOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.UOBTree import UOBTree
return UOBTree()


class UOBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):

def _makeOne(self):
from BTrees.UOBTree import UOBTreePy
return UOBTreePy()


class _TestUOBTreesBase(TypeTest):

def _stringraises(self):
Expand Down
25 changes: 1 addition & 24 deletions BTrees/tests/test_UUBTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .common import makeBuilder
from .common import UnsignedMixin
from .common import UnsignedError
from BTrees.UUBTree import using64bits #XXX Ugly, but unavoidable



class UUBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
Expand Down Expand Up @@ -131,29 +131,6 @@ def _makeOne(self):
return UUBTreePy()


if using64bits:

class UUBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.UUBTree import UUBTree
return UUBTree()

def getTwoValues(self):
return 1, 2

class UUBTreeTestPy(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):

def _makeOne(self):
from BTrees.UUBTree import UUBTreePy
return UUBTreePy()

def getTwoValues(self):
return 1, 2


class _TestUUBTreesBase(object):

def testNonIntegerKeyRaises(self):
Expand Down
Loading

0 comments on commit f3b7be2

Please sign in to comment.