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 Mar 5, 2020
1 parent 3df50aa commit 7b064fc
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 87 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
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Nothing changed yet.

- Fix the value for ``BTrees.OIBTree.using64bits`` when using the pure Python
implementation (PyPy and when ``PURE_PYTHON`` is in the environment).

4.6.1 (2019-11-07)
------------------
Expand Down

0 comments on commit 7b064fc

Please sign in to comment.