Commit 2038bcb6 authored by Jason Madden's avatar Jason Madden

Reduce the boilerplate needed to add new tree types.

Generate the Python modules and test modules based off a description
of the datatype.

Several tests that were previously only used for a specific classes
are now generalized and added to most trees, such as testing
non-compliant keys and testing overflow for bounded values.

Also always raise ``OverflowError`` for integer keys/values out of range.
parent 3cbf0dcf
......@@ -57,7 +57,9 @@
** self The bucket
** keyarg The key to look for
** has_key Boolean; if true, return a true/false result; else return
** the value associated with the key.
** the value associated with the key. When true, ignore the TypeError from
** a key conversion issue, instead
** transforming it into a KeyError.
**
** Return
** If has_key:
......@@ -81,7 +83,15 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
int copied = 1;
COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return NULL;
UNLESS (copied)
{
if (has_key && PyErr_ExceptionMatches(PyExc_TypeError))
{
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, keyarg);
}
return NULL;
}
UNLESS (PER_USE(self)) return NULL;
......@@ -106,7 +116,17 @@ Done:
static PyObject *
bucket_getitem(Bucket *self, PyObject *key)
{
return _bucket_get(self, key, 0);
PyObject* result;
result = _bucket_get(self, key, 0);
if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError))
{
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, key);
}
return result;
}
/*
......@@ -1448,6 +1468,10 @@ bucket_contains(Bucket *self, PyObject *key)
result = INT_AS_LONG(asobj) ? 1 : 0;
Py_DECREF(asobj);
}
else if (PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_Clear();
result = 0;
}
return result;
}
......@@ -1465,6 +1489,10 @@ bucket_getm(Bucket *self, PyObject *args)
r = _bucket_get(self, key, 0);
if (r)
return r;
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, key);
}
if (!PyErr_ExceptionMatches(PyExc_KeyError))
return NULL;
PyErr_Clear();
......
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IFBucket', 'IFSet', 'IFBTree', 'IFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IFBucketPy._mapping_type = IFBucketPy._bucket_type = IFBucketPy
IFBucketPy._set_type = IFSetPy
IFSetPy._mapping_type = IFBucketPy
IFSetPy._set_type = IFSetPy._bucket_type = IFSetPy
IFBTreePy._mapping_type = IFBTreePy._bucket_type = IFBucketPy
IFBTreePy._set_type = IFSetPy
IFTreeSetPy._mapping_type = IFBucketPy
IFTreeSetPy._set_type = IFTreeSetPy._bucket_type = IFSetPy
differencePy = _set_operation(_difference, IFSetPy)
unionPy = _set_operation(_union, IFSetPy)
intersectionPy = _set_operation(_intersection, IFSetPy)
multiunionPy = _set_operation(_multiunion, IFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, IFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IIBucket', 'IISet', 'IIBTree', 'IITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IIBucketPy._mapping_type = IIBucketPy._bucket_type = IIBucketPy
IIBucketPy._set_type = IISetPy
IISetPy._mapping_type = IIBucketPy
IISetPy._set_type = IISetPy._bucket_type = IISetPy
IIBTreePy._mapping_type = IIBTreePy._bucket_type = IIBucketPy
IIBTreePy._set_type = IISetPy
IITreeSetPy._mapping_type = IIBucketPy
IITreeSetPy._set_type = IITreeSetPy._bucket_type = IISetPy
differencePy = _set_operation(_difference, IISetPy)
unionPy = _set_operation(_union, IISetPy)
intersectionPy = _set_operation(_intersection, IISetPy)
multiunionPy = _set_operation(_multiunion, IISetPy)
weightedUnionPy = _set_operation(_weightedUnion, IISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IOBucket', 'IOSet', 'IOBTree', 'IOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = False
class IOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOSetPy(Set):
_to_key = _to_key
class IOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class IOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IOBucketPy._mapping_type = IOBucketPy._bucket_type = IOBucketPy
IOBucketPy._set_type = IOSetPy
IOSetPy._mapping_type = IOBucketPy
IOSetPy._set_type = IOSetPy._bucket_type = IOSetPy
IOBTreePy._mapping_type = IOBTreePy._bucket_type = IOBucketPy
IOBTreePy._set_type = IOSetPy
IOTreeSetPy._mapping_type = IOBucketPy
IOTreeSetPy._set_type = IOTreeSetPy._bucket_type = IOSetPy
differencePy = _set_operation(_difference, IOSetPy)
unionPy = _set_operation(_union, IOSetPy)
intersectionPy = _set_operation(_intersection, IOSetPy)
multiunionPy = _set_operation(_multiunion, IOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IUBucket', 'IUSet', 'IUBTree', 'IUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IUBucketPy._mapping_type = IUBucketPy._bucket_type = IUBucketPy
IUBucketPy._set_type = IUSetPy
IUSetPy._mapping_type = IUBucketPy
IUSetPy._set_type = IUSetPy._bucket_type = IUSetPy
IUBTreePy._mapping_type = IUBTreePy._bucket_type = IUBucketPy
IUBTreePy._set_type = IUSetPy
IUTreeSetPy._mapping_type = IUBucketPy
IUTreeSetPy._set_type = IUTreeSetPy._bucket_type = IUSetPy
differencePy = _set_operation(_difference, IUSetPy)
unionPy = _set_operation(_union, IUSetPy)
intersectionPy = _set_operation(_intersection, IUSetPy)
multiunionPy = _set_operation(_multiunion, IUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, IUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LFBucket', 'LFSet', 'LFBTree', 'LFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LFBucketPy._mapping_type = LFBucketPy._bucket_type = LFBucketPy
LFBucketPy._set_type = LFSetPy
LFSetPy._mapping_type = LFBucketPy
LFSetPy._set_type = LFSetPy._bucket_type = LFSetPy
LFBTreePy._mapping_type = LFBTreePy._bucket_type = LFBucketPy
LFBTreePy._set_type = LFSetPy
LFTreeSetPy._mapping_type = LFBucketPy
LFTreeSetPy._set_type = LFTreeSetPy._bucket_type = LFSetPy
differencePy = _set_operation(_difference, LFSetPy)
unionPy = _set_operation(_union, LFSetPy)
intersectionPy = _set_operation(_intersection, LFSetPy)
multiunionPy = _set_operation(_multiunion, LFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LLBucket', 'LLSet', 'LLBTree', 'LLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LLBucketPy._mapping_type = LLBucketPy._bucket_type = LLBucketPy
LLBucketPy._set_type = LLSetPy
LLSetPy._mapping_type = LLBucketPy
LLSetPy._set_type = LLSetPy._bucket_type = LLSetPy
LLBTreePy._mapping_type = LLBTreePy._bucket_type = LLBucketPy
LLBTreePy._set_type = LLSetPy
LLTreeSetPy._mapping_type = LLBucketPy
LLTreeSetPy._set_type = LLTreeSetPy._bucket_type = LLSetPy
differencePy = _set_operation(_difference, LLSetPy)
unionPy = _set_operation(_union, LLSetPy)
intersectionPy = _set_operation(_intersection, LLSetPy)
multiunionPy = _set_operation(_multiunion, LLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LOBucket', 'LOSet', 'LOBTree', 'LOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = True
class LOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOSetPy(Set):
_to_key = _to_key
class LOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class LOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LOBucketPy._mapping_type = LOBucketPy._bucket_type = LOBucketPy
LOBucketPy._set_type = LOSetPy
LOSetPy._mapping_type = LOBucketPy
LOSetPy._set_type = LOSetPy._bucket_type = LOSetPy
LOBTreePy._mapping_type = LOBTreePy._bucket_type = LOBucketPy
LOBTreePy._set_type = LOSetPy
LOTreeSetPy._mapping_type = LOBucketPy
LOTreeSetPy._set_type = LOTreeSetPy._bucket_type = LOSetPy
differencePy = _set_operation(_difference, LOSetPy)
unionPy = _set_operation(_union, LOSetPy)
intersectionPy = _set_operation(_intersection, LOSetPy)
multiunionPy = _set_operation(_multiunion, LOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LQBucket', 'LQSet', 'LQBTree', 'LQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LQBucketPy._mapping_type = LQBucketPy._bucket_type = LQBucketPy
LQBucketPy._set_type = LQSetPy
LQSetPy._mapping_type = LQBucketPy
LQSetPy._set_type = LQSetPy._bucket_type = LQSetPy
LQBTreePy._mapping_type = LQBTreePy._bucket_type = LQBucketPy
LQBTreePy._set_type = LQSetPy
LQTreeSetPy._mapping_type = LQBucketPy
LQTreeSetPy._set_type = LQTreeSetPy._bucket_type = LQSetPy
differencePy = _set_operation(_difference, LQSetPy)
unionPy = _set_operation(_union, LQSetPy)
intersectionPy = _set_operation(_intersection, LQSetPy)
multiunionPy = _set_operation(_multiunion, LQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OIBucket', 'OISet', 'OIBTree', 'OITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_int as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = False
class OIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OIBucketPy._mapping_type = OIBucketPy._bucket_type = OIBucketPy
OIBucketPy._set_type = OISetPy
OISetPy._mapping_type = OIBucketPy
OISetPy._set_type = OISetPy._bucket_type = OISetPy
OIBTreePy._mapping_type = OIBTreePy._bucket_type = OIBucketPy
OIBTreePy._set_type = OISetPy
OITreeSetPy._mapping_type = OIBucketPy
OITreeSetPy._set_type = OITreeSetPy._bucket_type = OISetPy
differencePy = _set_operation(_difference, OISetPy)
unionPy = _set_operation(_union, OISetPy)
intersectionPy = _set_operation(_intersection, OISetPy)
weightedUnionPy = _set_operation(_weightedUnion, OISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OLBucket', 'OLSet', 'OLBTree', 'OLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OLBucketPy._mapping_type = OLBucketPy._bucket_type = OLBucketPy
OLBucketPy._set_type = OLSetPy
OLSetPy._mapping_type = OLBucketPy
OLSetPy._set_type = OLSetPy._bucket_type = OLSetPy
OLBTreePy._mapping_type = OLBTreePy._bucket_type = OLBucketPy
OLBTreePy._set_type = OLSetPy
OLTreeSetPy._mapping_type = OLBucketPy
OLTreeSetPy._set_type = OLTreeSetPy._bucket_type = OLSetPy
differencePy = _set_operation(_difference, OLSetPy)
unionPy = _set_operation(_union, OLSetPy)
intersectionPy = _set_operation(_intersection, OLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OOBucket', 'OOSet', 'OOBTree', 'OOTreeSet',
'union', 'intersection','difference',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectObjectBTreeModule
from ._base import Bucket
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 30
_TREE_SIZE = 250
using64bits = False
class OOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
class OOSetPy(Set):
_to_key = _to_key
class OOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
class OOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class OOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OOBucketPy._mapping_type = OOBucketPy._bucket_type = OOBucketPy
OOBucketPy._set_type = OOSetPy
OOSetPy._mapping_type = OOBucketPy
OOSetPy._set_type = OOSetPy._bucket_type = OOSetPy
OOBTreePy._mapping_type = OOBTreePy._bucket_type = OOBucketPy
OOBTreePy._set_type = OOSetPy
OOTreeSetPy._mapping_type = OOBucketPy
OOTreeSetPy._set_type = OOTreeSetPy._bucket_type = OOSetPy
differencePy = _set_operation(_difference, OOSetPy)
unionPy = _set_operation(_union, OOSetPy)
intersectionPy = _set_operation(_intersection, OOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OQBucket', 'OQSet', 'OQBTree', 'OQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OQBucketPy._mapping_type = OQBucketPy._bucket_type = OQBucketPy
OQBucketPy._set_type = OQSetPy
OQSetPy._mapping_type = OQBucketPy
OQSetPy._set_type = OQSetPy._bucket_type = OQSetPy
OQBTreePy._mapping_type = OQBTreePy._bucket_type = OQBucketPy
OQBTreePy._set_type = OQSetPy
OQTreeSetPy._mapping_type = OQBucketPy
OQTreeSetPy._set_type = OQTreeSetPy._bucket_type = OQSetPy
differencePy = _set_operation(_difference, OQSetPy)
unionPy = _set_operation(_union, OQSetPy)
intersectionPy = _set_operation(_intersection, OQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OUBucket', 'OUSet', 'OUBTree', 'OUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OUBucketPy._mapping_type = OUBucketPy._bucket_type = OUBucketPy
OUBucketPy._set_type = OUSetPy
OUSetPy._mapping_type = OUBucketPy
OUSetPy._set_type = OUSetPy._bucket_type = OUSetPy
OUBTreePy._mapping_type = OUBTreePy._bucket_type = OUBucketPy
OUBTreePy._set_type = OUSetPy
OUTreeSetPy._mapping_type = OUBucketPy
OUTreeSetPy._set_type = OUTreeSetPy._bucket_type = OUSetPy
differencePy = _set_operation(_difference, OUSetPy)
unionPy = _set_operation(_union, OUSetPy)
intersectionPy = _set_operation(_intersection, OUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QFBucket', 'QFSet', 'QFBTree', 'QFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QFBucketPy._mapping_type = QFBucketPy._bucket_type = QFBucketPy
QFBucketPy._set_type = QFSetPy
QFSetPy._mapping_type = QFBucketPy
QFSetPy._set_type = QFSetPy._bucket_type = QFSetPy
QFBTreePy._mapping_type = QFBTreePy._bucket_type = QFBucketPy
QFBTreePy._set_type = QFSetPy
QFTreeSetPy._mapping_type = QFBucketPy
QFTreeSetPy._set_type = QFTreeSetPy._bucket_type = QFSetPy
differencePy = _set_operation(_difference, QFSetPy)
unionPy = _set_operation(_union, QFSetPy)
intersectionPy = _set_operation(_intersection, QFSetPy)
multiunionPy = _set_operation(_multiunion, QFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QLBucket', 'QLSet', 'QLBTree', 'QLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QLBucketPy._mapping_type = QLBucketPy._bucket_type = QLBucketPy
QLBucketPy._set_type = QLSetPy
QLSetPy._mapping_type = QLBucketPy
QLSetPy._set_type = QLSetPy._bucket_type = QLSetPy
QLBTreePy._mapping_type = QLBTreePy._bucket_type = QLBucketPy
QLBTreePy._set_type = QLSetPy
QLTreeSetPy._mapping_type = QLBucketPy
QLTreeSetPy._set_type = QLTreeSetPy._bucket_type = QLSetPy
differencePy = _set_operation(_difference, QLSetPy)
unionPy = _set_operation(_union, QLSetPy)
intersectionPy = _set_operation(_intersection, QLSetPy)
multiunionPy = _set_operation(_multiunion, QLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QOBucket', 'QOSet', 'QOBTree', 'QOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = True
class QOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOSetPy(Set):
_to_key = _to_key
class QOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class QOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QOBucketPy._mapping_type = QOBucketPy._bucket_type = QOBucketPy
QOBucketPy._set_type = QOSetPy
QOSetPy._mapping_type = QOBucketPy
QOSetPy._set_type = QOSetPy._bucket_type = QOSetPy
QOBTreePy._mapping_type = QOBTreePy._bucket_type = QOBucketPy
QOBTreePy._set_type = QOSetPy
QOTreeSetPy._mapping_type = QOBucketPy
QOTreeSetPy._set_type = QOTreeSetPy._bucket_type = QOSetPy
differencePy = _set_operation(_difference, QOSetPy)
unionPy = _set_operation(_union, QOSetPy)
intersectionPy = _set_operation(_intersection, QOSetPy)
multiunionPy = _set_operation(_multiunion, QOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QQBucket', 'QQSet', 'QQBTree', 'QQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QQBucketPy._mapping_type = QQBucketPy._bucket_type = QQBucketPy
QQBucketPy._set_type = QQSetPy
QQSetPy._mapping_type = QQBucketPy
QQSetPy._set_type = QQSetPy._bucket_type = QQSetPy
QQBTreePy._mapping_type = QQBTreePy._bucket_type = QQBucketPy
QQBTreePy._set_type = QQSetPy
QQTreeSetPy._mapping_type = QQBucketPy
QQTreeSetPy._set_type = QQTreeSetPy._bucket_type = QQSetPy
differencePy = _set_operation(_difference, QQSetPy)
unionPy = _set_operation(_union, QQSetPy)
intersectionPy = _set_operation(_intersection, QQSetPy)
multiunionPy = _set_operation(_multiunion, QQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UFBucket', 'UFSet', 'UFBTree', 'UFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UFBucketPy._mapping_type = UFBucketPy._bucket_type = UFBucketPy
UFBucketPy._set_type = UFSetPy
UFSetPy._mapping_type = UFBucketPy
UFSetPy._set_type = UFSetPy._bucket_type = UFSetPy
UFBTreePy._mapping_type = UFBTreePy._bucket_type = UFBucketPy
UFBTreePy._set_type = UFSetPy
UFTreeSetPy._mapping_type = UFBucketPy
UFTreeSetPy._set_type = UFTreeSetPy._bucket_type = UFSetPy
differencePy = _set_operation(_difference, UFSetPy)
unionPy = _set_operation(_union, UFSetPy)
intersectionPy = _set_operation(_intersection, UFSetPy)
multiunionPy = _set_operation(_multiunion, UFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UIBucket', 'UISet', 'UIBTree', 'UITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_int as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UIBucketPy._mapping_type = UIBucketPy._bucket_type = UIBucketPy
UIBucketPy._set_type = UISetPy
UISetPy._mapping_type = UIBucketPy
UISetPy._set_type = UISetPy._bucket_type = UISetPy
UIBTreePy._mapping_type = UIBTreePy._bucket_type = UIBucketPy
UIBTreePy._set_type = UISetPy
UITreeSetPy._mapping_type = UIBucketPy
UITreeSetPy._set_type = UITreeSetPy._bucket_type = UISetPy
differencePy = _set_operation(_difference, UISetPy)
unionPy = _set_operation(_union, UISetPy)
intersectionPy = _set_operation(_intersection, UISetPy)
multiunionPy = _set_operation(_multiunion, UISetPy)
weightedUnionPy = _set_operation(_weightedUnion, UISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UOBucket', 'UOSet', 'UOBTree', 'UOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = False
class UOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOSetPy(Set):
_to_key = _to_key
class UOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class UOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UOBucketPy._mapping_type = UOBucketPy._bucket_type = UOBucketPy
UOBucketPy._set_type = UOSetPy
UOSetPy._mapping_type = UOBucketPy
UOSetPy._set_type = UOSetPy._bucket_type = UOSetPy
UOBTreePy._mapping_type = UOBTreePy._bucket_type = UOBucketPy
UOBTreePy._set_type = UOSetPy
UOTreeSetPy._mapping_type = UOBucketPy
UOTreeSetPy._set_type = UOTreeSetPy._bucket_type = UOSetPy
differencePy = _set_operation(_difference, UOSetPy)
unionPy = _set_operation(_union, UOSetPy)
intersectionPy = _set_operation(_intersection, UOSetPy)
multiunionPy = _set_operation(_multiunion, UOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UUBucket', 'UUSet', 'UUBTree', 'UUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UUBucketPy._mapping_type = UUBucketPy._bucket_type = UUBucketPy
UUBucketPy._set_type = UUSetPy
UUSetPy._mapping_type = UUBucketPy
UUSetPy._set_type = UUSetPy._bucket_type = UUSetPy
UUBTreePy._mapping_type = UUBTreePy._bucket_type = UUBucketPy
UUBTreePy._set_type = UUSetPy
UUTreeSetPy._mapping_type = UUBucketPy
UUTreeSetPy._set_type = UUTreeSetPy._bucket_type = UUSetPy
differencePy = _set_operation(_difference, UUSetPy)
unionPy = _set_operation(_union, UUSetPy)
intersectionPy = _set_operation(_intersection, UUSetPy)
multiunionPy = _set_operation(_multiunion, UUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
......@@ -12,15 +12,65 @@
#
#############################################################################
import sys
import zope.interface
import BTrees.Interfaces
from ._module_builder import create_module
__all__ = [
'family32',
'family64',
]
_FAMILIES = (
# Signed 32-bit keys
"IO", # object value
"II", # self value
"IF", # float value
"IU", # opposite sign value
# Unsigned 32-bit keys
"UO", # object value
"UU", # self value
"UF", # float value
"UI", # opposite sign value
# Signed 64-bit keys
"LO", # object value
"LL", # self value
"LF", # float value
"LQ", # opposite sign value
# Unsigned 64-bit keys
"QO", # object value
"QQ", # self value
"QF", # float value
"QL", # opposite sign value
# Object keys
"OO", # object
"OI", # 32-bit signed
"OU", # 32-bit unsigned
"OL", # 64-bit signed
"OQ", # 64-bit unsigned
)
# XXX: Do this without completely ruining
# pylint and other static analysis.
for family in _FAMILIES:
mod = create_module(family)
name = vars(mod)['__name__']
sys.modules[name] = mod
globals()[name.split('.', 1)[1]] = mod
__all__.append(name)
@zope.interface.implementer(BTrees.Interfaces.IBTreeFamily)
class _Family(object):
from BTrees import OOBTree as OO
_BITSIZE = 0
minint = maxint = maxuint = 0
minint = maxint = maxuint = None
def __init__(self):
self.maxint = int(2 ** (self._BITSIZE - 1) - 1)
self.minint = int(-self.maxint - 1)
self.maxuint = int(2 ** self._BITSIZE - 1)
def __str__(self):
return (
......@@ -49,10 +99,6 @@ class _Family32(_Family):
from BTrees import UOBTree as UO
from BTrees import UUBTree as UU
maxuint = int(2**32)
maxint = int(2**31-1)
minint = -maxint - 1
def __reduce__(self):
return _family32, ()
......@@ -71,10 +117,6 @@ class _Family64(_Family):
from BTrees import QOBTree as UO
from BTrees import QQBTree as UU
maxuint = 2**64
maxint = 2**63-1
minint = -maxint - 1
def __reduce__(self):
return _family64, ()
......
......@@ -14,18 +14,24 @@
"""Python BTree implementation
"""
from struct import Struct
from struct import error as struct_error
from operator import index
from persistent import Persistent
from .Interfaces import BTreesConflictError
from ._compat import PY3
from ._compat import compare
from ._compat import int_types
from ._compat import xrange
# XXX: Fix these. These ignores are temporary to
# reduce the noise and help find specific issues during
# refactoring
# pylint:disable=too-many-lines,fixme,protected-access
# pylint:disable=attribute-defined-outside-init,redefined-builtin,no-else-return
# pylint:disable=redefined-outer-name,bad-continuation,unused-variable
# pylint:disable=too-many-branches,too-many-statements,arguments-differ,assigning-non-slot
# pylint:disable=superfluous-parens,inconsistent-return-statements,unidiomatic-typecheck
# pylint:disable=deprecated-method,consider-using-enumerate
_marker = object()
......@@ -33,6 +39,11 @@ _marker = object()
class _Base(Persistent):
__slots__ = ()
# This is used to allocate storage for the keys.
# It's probably here so that we could, for example, use
# an ``array.array`` for native types. But nothing actually does
# that, everything is stored boxed.
# TODO: Figure out why not.
_key_type = list
def __init__(self, items=None):
......@@ -190,7 +201,13 @@ class _BucketBase(_Base):
return iter(self._keys)
def __contains__(self, key):
return (self._search(self._to_key(key)) >= 0)
try:
tree_key = self._to_key(key)
except TypeError:
# Can't convert the key, so can't possibly be in the tree
return False
return (self._search(tree_key) >= 0)
has_key = __contains__
......@@ -252,25 +269,6 @@ class _SetIteration(object):
return self
_object_lt = getattr(object, '__lt__', _marker)
def _no_default_comparison(key):
# Enforce test that key has non-default comparison.
if key is None:
return
if type(key) is object:
raise TypeError("Can't use object() as keys")
lt = getattr(key, '__lt__', None)
if lt is not None:
# CPython 3.x follows PEP 252, defining '__objclass__'
if getattr(lt, '__objclass__', None) is object:
lt = None # pragma: no cover Py3k
# PyPy3 doesn't follow PEP 252, but defines '__func__'
elif getattr(lt, '__func__', None) is _object_lt:
lt = None # pragma: no cover PyPy3
if (lt is None and
getattr(key, '__cmp__', None) is None):
raise TypeError("Object has default comparison")
class Bucket(_BucketBase):
......@@ -308,7 +306,6 @@ class Bucket(_BucketBase):
raise TypeError('items must be a sequence of 2-tuples')
def __setitem__(self, key, value):
_no_default_comparison(key)
self._set(self._to_key(key), self._to_value(value))
def __delitem__(self, key):
......@@ -319,13 +316,23 @@ class Bucket(_BucketBase):
self._values = self._value_type()
def get(self, key, default=None):
index = self._search(self._to_key(key))
try:
key = self._to_key(key)
except TypeError:
# Can't convert, cannot possibly be present.
return default
index = self._search(key)
if index < 0:
return default
return self._values[index]
def __getitem__(self, key):
index = self._search(self._to_key(key))
try:
tree_key = self._to_key(key)
except TypeError:
# Can't convert, so cannot possibly be present.
raise KeyError(key)
index = self._search(tree_key)
if index < 0:
raise KeyError(key)
return self._values[index]
......@@ -809,7 +816,6 @@ class _Tree(_Base):
set(*i)
def __setitem__(self, key, value):
_no_default_comparison(key)
self._set(self._to_key(key), self._to_value(value))
def __delitem__(self, key):
......@@ -990,7 +996,7 @@ class _Tree(_Base):
if isinstance(first.child, type(self)):
next._firstbucket = first.child._firstbucket
else:
next._firstbucket = first.child;
next._firstbucket = first.child
return next
def _del(self, key):
......@@ -1111,7 +1117,7 @@ class _Tree(_Base):
"BTree has firstbucket different than "
"its first child's firstbucket")
for i in range(len(data)-1):
data[i].child._check(data[i+1].child._firstbucket)
data[i].child._check(data[i+1].child._firstbucket)
data[-1].child._check(nextbucket)
elif child_class is self._bucket_type:
assert_(self._firstbucket is data[0].child,
......@@ -1297,13 +1303,23 @@ class TreeSet(_Tree):
class set_operation(object):
__slots__ = ('func',
'set_type',
)
__slots__ = (
'func',
'set_type',
'__name__',
'_module',
)
def __init__(self, func, set_type):
self.func = func
self.set_type = set_type
self.__name__ = func.__name__
self._module = func.__module__
__module__ = property(
lambda self: self._module,
lambda self, nv: setattr(self, '_module', nv)
)
def __call__(self, *a, **k):
return self.func(self.set_type, *a, **k)
......@@ -1492,83 +1508,6 @@ def multiunion(set_type, seqs):
result.update(s)
return result
def to_ob(self, v):
return v
def _packer_unpacker(struct_format):
s = Struct(struct_format)
return s.pack, s.unpack
int_pack, int_unpack = _packer_unpacker('i')
def to_int(self, v):
try:
int_pack(index(v))
except (struct_error, TypeError):
raise TypeError('32-bit integer expected')
return int(v)
# PyPy can raise ValueError converting a negative number to a
# unsigned value.
uint_pack, uint_unpack = _packer_unpacker('I')
def to_uint(self, v):
try:
uint_pack(index(v))
except (struct_error, TypeError, ValueError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 32-bit integer expected')
return int(v)
float_pack = _packer_unpacker('f')[0]
def to_float(self, v):
try:
float_pack(v)
except struct_error:
raise TypeError('float expected')
return float(v)
long_pack, long_unpack = _packer_unpacker('q')
def to_long(self, v):
try:
long_pack(index(v))
except (struct_error, TypeError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('64-bit integer expected')
return int(v)
ulong_pack, ulong_unpack = _packer_unpacker('Q')
def to_ulong(self, v):
try:
ulong_pack(index(v))
except (struct_error, TypeError, ValueError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 64-bit integer expected')
return int(v)
def to_bytes(l):
def to(self, v):
if not (isinstance(v, bytes) and len(v) == l):
raise TypeError("%s-byte array expected" % l)
return v
return to
tos = dict(I=to_int, L=to_long, F=to_float, O=to_ob, U=to_uint, Q=to_ulong)
MERGE_DEFAULT_int = 1
MERGE_DEFAULT_float = 1.0
def MERGE(self, value1, weight1, value2, weight2):
return (value1 * weight1) + (value2 * weight2)
......
......@@ -97,4 +97,4 @@ def import_c_extension(mod_globals):
mod_globals[name] = mod_globals[prefix + name]
# Cleanup
del mod_globals['import_c_extension']
mod_globals.pop('import_c_extension', None)
##############################################################################
#
# Copyright Zope Foundation 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.
#
##############################################################################
"""
Descriptions of the datatypes supported by this package.
"""
from __future__ import absolute_import
from operator import index as object_to_index
from struct import Struct
from struct import error as struct_error
from ._compat import int_types
from .utils import Lazy
class DataType(object):
"""
Describes a data type used as a value.
Subclasses will be defined for each particular
supported type.
"""
# The name for this datatype as used in interface names.
long_name = None
# The prefix code for this data type. Usually a single letter.
prefix_code = None
# The multiplication identity for this data type. Used in
# combining (merging) data types. Leave undefined if this is
# not a valid operation.
multiplication_identity = None
# Does the data take up 64-bits? Currently only relevant for the
# integer key types.
using64bits = False
def __init__(self):
if not self.prefix_code:
self.prefix_code = type(self).__name__
def __call__(self, item):
"""
Convert *item* into the correct format and return it.
If this cannot be done, raise an appropriate exception.
"""
raise NotImplementedError
def apply_weight(self, item, weight): # pylint:disable=unused-argument
"""
Apply a *weight* multiplier to *item*.
Used when merging data structures. The *item* will be a
value.
"""
return item
def as_value_type(self):
# Because ``O'`` is used for both key and value,
# we can override this to get the less restrictive value type.
return self
def supports_value_union(self):
raise NotImplementedError
def getTwoExamples(self):
"""
Provide two distinct (non equal) examples acceptable to `__call__`.
This is for testing.
"""
return "object1", "object2"
def get_lower_bound(self):
"""
If there is a lower bound (inclusive) on the data type, return
it. Otherwise, return ``None``.
For integer types, this will only depend on whether it
supports signed or unsigned values, and the answer will be 0
or a negative number. For object types, ``None`` is always
defined to sort as the lowest bound.
This can be relevant for both key and value types.
"""
return None
def get_upper_bound(self):
"""
If there is an upper bound (inclusive) on the data type,
return it. Otherwise, return ``None``.
Remarks are as for `get_lower_bound`.
"""
return None
class KeyDataType(DataType):
"""
Describes a data type that has additional restrictions allowing it
to be used as a key.
"""
# When used as the key, this number determines the
# max_internal_size.
tree_size = 500
default_bucket_size = 120
def __call__(self, item):
raise NotImplementedError
def bucket_size_for_value(self, value_type):
"""
What should the bucket (``max_leaf_size``) be when
this data type is used with the given *value_type*?
"""
if isinstance(value_type, Any):
return self.default_bucket_size // 2
return self.default_bucket_size
class Any(DataType):
"""
Arbitrary Python objects.
"""
prefix_code = 'O'
long_name = 'Object'
def __call__(self, item):
return item
def supports_value_union(self):
return False
class O(KeyDataType):
"""
Arbitrary (sortable) Python objects.
"""
long_name = 'Object'
tree_size = 250
default_bucket_size = 60
def as_value_type(self):
return Any()
def supports_value_union(self):
return False
@staticmethod
def _check_default_comparison(
item,
# PyPy2 doesn't define __lt__ on object; PyPy3 and
# CPython 2 and 3 do.
_object_lt=getattr(object, '__lt__', object())
):
# Enforce test that key has non-default comparison.
# (With the exception of None, because we define a sort order
# for it.)
if item is None:
return
if type(item) is object: # pylint:disable=unidiomatic-typecheck
raise TypeError("Can't use object() as keys")
# Now more complicated checks to be sure we didn't
# inherit default comparison on any version of Python.
# TODO: Using a custom ABC and doing ``isinstance(item, NoDefaultComparison)``
# would automatically gain us caching.
# XXX: Comparisons only use special methods defined on the
# type, not instance variables. So shouldn't this be getattr(type(key)...)?
# Note that changes some things below; for example, on CPython 2,
# every subclass of object inherits __lt__ (unless it overrides), and it
# has __objclass__ of ``type`` (of course it is also the same object
# as ``_object_lt`` at that point). Also, weirdly, CPython 2 classes inherit
# ``__lt__``, but *instances* do not.
lt = getattr(item, '__lt__', None)
if lt is not None:
# CPython 2 and 3 follow PEP 252, defining '__objclass__'
# for methods of builtin types like str; methods of
# classes defined in Python don't get it. ``__objclass__``
if getattr(lt, '__objclass__', None) is object:
lt = None # pragma: no cover Py3k
# PyPy3 doesn't follow PEP 252, but defines '__func__'
elif getattr(lt, '__func__', None) is _object_lt:
lt = None # pragma: no cover PyPy3
if (lt is None
# TODO: Shouldn't we only check __cmp__ on Python 2?
# Python 3 won't use it.
and getattr(item, '__cmp__', None) is None):
raise TypeError("Object has default comparison")
def __call__(self, item):
self._check_default_comparison(item)
return item
class _AbstractNativeDataType(KeyDataType):
"""
Uses `struct.Struct` to verify that the data can fit into a native
type.
"""
_struct_format = None
_as_python_type = NotImplementedError
_required_python_type = object
_error_description = None
_as_packable = object_to_index
@Lazy
def _check_native(self):
return Struct(self._struct_format).pack
def __call__(self, item):
try:
self._check_native(self._as_packable(item)) # pylint:disable=too-many-function-args
except (struct_error, TypeError, ValueError):
# PyPy can raise ValueError converting a negative number to a
# unsigned value.
if isinstance(item, int_types):
raise OverflowError("Value out of range", item)
raise TypeError(self._error_description)
return self._as_python_type(item)
def apply_weight(self, item, weight):
return item * weight
def supports_value_union(self):
return True
class _AbstractIntDataType(_AbstractNativeDataType):
_as_python_type = int
_required_python_type = int_types
multiplication_identity = 1
long_name = "Integer"
def getTwoExamples(self):
return 1, 2
# On Python 2, it's important for these values to be actual `int`
# values, not `long` when they fit; passing a value that's too big
# to `int` will still result in it being a `long`. For some reason
# on Windows, even the 32-bit values somehow wind up as longs
# unless we do the conversion.
def get_lower_bound(self):
exp = 64 if self.using64bits else 32
exp -= 1
return int(-(2 ** exp))
def get_upper_bound(self):
exp = 64 if self.using64bits else 32
exp -= 1
return int(2 ** exp - 1)
class _AbstractUIntDataType(_AbstractIntDataType):
long_name = 'Unsigned'
def get_lower_bound(self):
return 0
def get_upper_bound(self):
exp = 64 if self.using64bits else 32
return int(2 ** exp - 1)
class I(_AbstractIntDataType):
_struct_format = 'i'
_error_description = "32-bit integer expected"
class U(_AbstractUIntDataType):
_struct_format = 'I'
_error_description = 'non-negative 32-bit integer expected'
class F(_AbstractNativeDataType):
_struct_format = 'f'
_as_python_type = float
_error_description = 'float expected'
_as_packable = lambda self, k: k # identity
multiplication_identity = 1.0
long_name = 'Float'
def getTwoExamples(self):
return 0.5, 1.5
class L(_AbstractIntDataType):
_struct_format = 'q'
_error_description = '64-bit integer expected'
using64bits = True
class Q(_AbstractUIntDataType):
_struct_format = 'Q'
_error_description = 'non-negative 64-bit integer expected'
using64bits = True
class Bytes(KeyDataType):
"""
An exact-length byte string type.
"""
__slots__ = ()
prefix_code = 'fs'
default_bucket_size = 500
def __init__(self, length):
super(Bytes, self).__init__()
self._length = length
def __call__(self, item):
if not isinstance(item, bytes) or len(item) != self._length:
raise TypeError("%s-byte array expected" % self._length)
return item
def supports_value_union(self):
return False
##############################################################################
#
# Copyright Zope Foundation 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.
#
##############################################################################
"""
Support functions to eliminate the boilerplate involved in defining
BTree modules.
"""
import sys
from zope.interface import directlyProvides
def _create_classes(
module_name, key_datatype, value_datatype,
):
from ._base import Bucket
from ._base import MERGE # Won't always want this.
from ._base import Set
from ._base import Tree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import _fix_pickle
classes = {}
prefix = key_datatype.prefix_code + value_datatype.prefix_code
for base in (
Bucket,
Set,
(Tree, 'BTree'),
TreeSet,
(_TreeIterator, 'TreeIterator'),
):
if isinstance(base, tuple):
base, base_name = base
else:
base_name = base.__name__
# XXX: Consider defining these with their natural names
# now and only aliasing them to 'Py' instead of the
# opposite. That should make pickling easier.
name = prefix + base_name + 'Py'
cls = type(name, (base,), dict(
_to_key=key_datatype,
_to_value=value_datatype,
MERGE=MERGE,
MERGE_WEIGHT=value_datatype.apply_weight,
MERGE_DEFAULT=value_datatype.multiplication_identity,
max_leaf_size=key_datatype.bucket_size_for_value(value_datatype),
max_internal_size=key_datatype.tree_size,
))
cls.__module__ = module_name
classes[cls.__name__] = cls
# Importing the C extension does this for the non-py
# classes.
# TODO: Unify that.
classes[base_name + 'Py'] = cls
for cls in classes.values():
cls._mapping_type = classes['BucketPy']
cls._set_type = classes['SetPy']
if 'Set' in cls.__name__:
cls._bucket_type = classes['SetPy']
else:
cls._bucket_type = classes['BucketPy']
return classes
def _create_set_operations(module_name, key_type, value_type, set_type):
from ._base import set_operation
from ._base import difference
from ._base import intersection
from ._base import multiunion
from ._base import union
from ._base import weightedIntersection
from ._base import weightedUnion
ops = {
op.__name__ + 'Py': set_operation(op, set_type)
for op in (
difference, intersection,
union,
) + (
(weightedIntersection, weightedUnion,)
if value_type.supports_value_union()
else ()
) + (
(multiunion,)
if key_type.supports_value_union()
else ()
)
}
for key, op in ops.items():
op.__module__ = module_name
op.__name__ = key
# TODO: Pickling. These things should be looked up by name.
return ops
def _create_globals(module_name, key_datatype, value_datatype):
classes = _create_classes(module_name, key_datatype, value_datatype)
set_type = classes['SetPy']
set_ops = _create_set_operations(module_name, key_datatype, value_datatype, set_type)
classes.update(set_ops)
return classes
def populate_module(mod_globals,
key_datatype, value_datatype,
interface, module=None):
from ._compat import import_c_extension
from ._base import _fix_pickle
module_name = mod_globals['__name__']
mod_globals.update(_create_globals(module_name, key_datatype, value_datatype))
# XXX: Maybe derive this from the values we create.
mod_all = (
'Bucket', 'Set', 'BTree', 'TreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
prefix = key_datatype.prefix_code + value_datatype.prefix_code
mod_all += tuple(prefix + c for c in ('Bucket', 'Set', 'BTree', 'TreeSet'))
mod_globals['__all__'] = tuple(c for c in mod_all if c in mod_globals)
mod_globals['using64bits'] = key_datatype.using64bits or value_datatype.using64bits
import_c_extension(mod_globals)
# XXX: We can probably do better than fix_pickle now;
# we can know if we're going to be renaming classes
# ahead of time.
_fix_pickle(mod_globals, module_name)
directlyProvides(module or sys.modules[module_name], interface)
def create_module(prefix):
import types
from . import _datatypes as datatypes
from . import Interfaces
mod = types.ModuleType('BTrees.' + prefix + 'BTree')
key_type = getattr(datatypes, prefix[0])()
val_type = getattr(datatypes, prefix[1])().as_value_type()
iface_name = 'I' + key_type.long_name + val_type.long_name + 'BTreeModule'
iface = getattr(Interfaces, iface_name)
populate_module(vars(mod), key_type, val_type, iface, mod)
return mod
......@@ -32,19 +32,19 @@ from ._base import TreeSet
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_bytes as _to_bytes
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
from ._datatypes import Bytes
_BUCKET_SIZE = 500
_TREE_SIZE = 500
using64bits = False
_to_key = _to_bytes(2)
_to_value = _to_bytes(6)
_to_key = Bytes(2)
_to_value = Bytes(6)
# XXX: Port this to use _module_builder.
class fsBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
......
......@@ -25,7 +25,7 @@
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if ((int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......@@ -61,7 +61,7 @@
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......
......@@ -31,7 +31,7 @@
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if ((int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......@@ -68,7 +68,7 @@
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......
# If tests is a package, debugging is a bit easier.
# Make this a package.
##############################################################################
#
# Copyright (c) Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import TestLongIntKeys
from .common import TestLongIntValues
class _FilteredModuleProxy(object):
"""
Accesses either ``<name>`` or ``<name>Py`` from a module.
This conveniently lets us avoid lots of 'getattr' calls.
Accessing ``def_<name>`` returns a callable that
returns ``<name>``. This is suitable for use as class attributes.
"""
# Lets us easily access by name a particular attribute
# in either the Python or C implementation, based on the
# suffix
def __init__(self, btree_module, suffix):
self.btree_module = btree_module
self.suffix = suffix
def __getattr__(self, name):
attr_name = name[4:] if name.startswith('def_') else name
attr_name += self.suffix
attr = getattr(self.btree_module, attr_name)
if name.startswith('def_'):
return staticmethod(lambda: attr)
return attr
def _flattened(*args):
def f(tuple_or_klass):
if isinstance(tuple_or_klass, tuple):
for x in tuple_or_klass:
for c in f(x):
yield c
else:
yield tuple_or_klass
return tuple(f(args))
class ClassBuilder(object):
# Use TestAuto as a prefix to avoid clashing with manual tests
TESTCASE_PREFIX = 'TestAuto'
def __init__(self, btree_module, btree_tests_base=BTreeTests):
self.btree_module = btree_module
self.key_type = btree_module.BTreePy._to_key
self.value_type = btree_module.BTreePy._to_value
class _BoundsMixin(object):
SUPPORTS_NEGATIVE_KEYS = self.key_type.get_lower_bound() != 0
SUPPORTS_NEGATIVE_VALUES = self.value_type.get_lower_bound() != 0
if SUPPORTS_NEGATIVE_KEYS:
KEY_RANDRANGE_ARGS = (-2000, 2001)
else:
KEY_RANDRANGE_ARGS = (0, 4002)
self.bounds_mixin = _BoundsMixin
self.btree_tests_base = btree_tests_base
self.prefix = btree_module.__name__.split('.', )[-1][:2]
self.test_module = 'BTrees.tests.test_' + self.prefix + 'BTree'
self.test_classes = {}
# Keep track of tested classes so that we don't
# double test in PURE_PYTHON mode (e.g., BTreePy is BTree)
self.tested_classes = set()
def _store_class(self, test_cls):
assert test_cls.__name__ not in self.test_classes, (test_cls, self.test_classes)
assert isinstance(test_cls, type)
assert issubclass(test_cls, unittest.TestCase)
self.test_classes[test_cls.__name__] = test_cls
def _fixup_and_store_class(self, btree_module, fut, test_cls):
base = [x for x in test_cls.__bases__
if x.__module__ != __name__ and x.__module__ != 'unittest'][0]
test_name = self._name_for_test(btree_module, fut, base)
test_cls.__name__ = test_name
test_cls.__module__ = self.test_module
test_cls.__qualname__ = self.test_module + '.' + test_name
self._store_class(test_cls)
def _name_for_test(self, btree_module, fut, test_base):
fut = getattr(fut, '__name__', fut)
fut = str(fut)
if isinstance(test_base, tuple):
test_base = test_base[0]
test_name = (
self.TESTCASE_PREFIX
+ (self.prefix if not fut.startswith(self.prefix) else '')
+ fut
+ test_base.__name__
+ btree_module.suffix
)
return test_name
def _needs_test(self, fut, test_base):
key = (fut, test_base)
if key in self.tested_classes:
return False
self.tested_classes.add(key)
return True
def _create_set_op_test(self, btree_module, base):
tree = btree_module.BTree
if not self._needs_test(tree, base):
return
class Test(self.bounds_mixin, base, unittest.TestCase):
# There are two set operation tests,
# Weighted and MultiUnion.
# These attributes are used in both
mkbucket = btree_module.Bucket
# Weighted uses union as a factory, self.union()(...).
# MultiUnion calls it directly.
__union = btree_module.def_union
def union(self, *args):
if args:
return self.__union()(*args)
return self.__union()
intersection = btree_module.def_intersection
# These are specific to Weighted; modules that
# don't have weighted values can'd do them.
if base is Weighted:
weightedUnion = btree_module.def_weightedUnion
weightedIntersection = btree_module.def_weightedIntersection
# These are specific to MultiUnion, and may not exist
# in key types that don't support unions (``'O'``)
multiunion = getattr(btree_module, 'multiunion', None)
mkset = btree_module.Set
mktreeset = btree_module.TreeSet
mkbtree = tree
def builders(self):
return (
btree_module.Bucket,
btree_module.BTree,
itemsToSet(btree_module.Set),
itemsToSet(btree_module.TreeSet)
)
self._fixup_and_store_class(btree_module, '', Test)
def _create_set_result_test(self, btree_module):
tree = btree_module.BTree
base = SetResult
if not self._needs_test(tree, base):
return
class Test(self.bounds_mixin, base, unittest.TestCase):
union = btree_module.union
intersection = btree_module.intersection
difference = btree_module.difference
def builders(self):
return (
btree_module.Set,
btree_module.TreeSet,
makeBuilder(btree_module.BTree),
makeBuilder(btree_module.Bucket)
)
self._fixup_and_store_class(btree_module, '', Test)
def _create_module_test(self):
from BTrees import Interfaces as interfaces
mod = self.btree_module
iface = getattr(interfaces, 'I' + self.key_type.long_name + self.value_type.long_name
+ 'BTreeModule')
class Test(ModuleTest, unittest.TestCase):
prefix = self.prefix
key_type = self.key_type
value_type = self.value_type
_getModule = lambda self: mod
_getInterface = lambda self: iface
self._fixup_and_store_class(_FilteredModuleProxy(self.btree_module, ''), '', Test)
def _create_type_tests(self, btree_module, type_name, test_bases):
tree = getattr(btree_module, type_name)
for test_base in test_bases:
if not self._needs_test(tree, test_base):
continue
test_name = self._name_for_test(btree_module, tree, test_base)
bases = _flattened(self.bounds_mixin, test_base, unittest.TestCase)
test_cls = type(test_name, bases, {
'__module__': self.test_module,
'_getTargetClass': lambda _, t=tree: t,
'getTwoKeys': self.key_type.getTwoExamples,
'getTwoValues': self.value_type.getTwoExamples,
'key_type': self.key_type,
'value_type': self.value_type,
})
self._store_class(test_cls)
def create_classes(self):
self._create_module_test()
btree_tests_base = (self.btree_tests_base,)
if self.key_type.using64bits:
btree_tests_base += (TestLongIntKeys,)
if self.value_type.using64bits:
btree_tests_base += (TestLongIntValues,)
set_ops = ()
if self.key_type.supports_value_union():
set_ops += (MultiUnion,)
if self.value_type.supports_value_union():
set_ops += (Weighted,)
for suffix in ('', 'Py'):
btree_module = _FilteredModuleProxy(self.btree_module, suffix)
for type_name, test_bases in (
('BTree', (InternalKeysMappingTest,
MappingConflictTestBase,
btree_tests_base)),
('Bucket', (MappingBase,
MappingConflictTestBase,)),
('Set', (ExtendedSetTests,
I_SetsBase,
SetConflictTestBase,)),
('TreeSet', (I_SetsBase,
NormalSetTests,
SetConflictTestBase,))
):
self._create_type_tests(btree_module, type_name, test_bases)
for test_base in set_ops:
self._create_set_op_test(btree_module, test_base)
self._create_set_result_test(btree_module)
def update_module(test_module_globals, btree_module, *args, **kwargs):
builder = ClassBuilder(btree_module, *args, **kwargs)
builder.create_classes()
test_module_globals.update(builder.test_classes)
......@@ -90,17 +90,6 @@ class SignedMixin(object):
KEY_RANDRANGE_ARGS = (-2000, 2001)
class UnsignedMixin(object):
SUPPORTS_NEGATIVE_KEYS = False
SUPPORTS_NEGATIVE_VALUES = False
KEY_RANDRANGE_ARGS = (0, 4002)
class UnsignedValuesMixin(SignedMixin):
SUPPORTS_NEGATIVE_VALUES = False
class UnsignedKeysMixin(UnsignedMixin):
SUPPORTS_NEGATIVE_VALUES = True
class Base(SignedMixin):
# Tests common to all types: sets, buckets, and BTrees
......@@ -998,14 +987,136 @@ class MappingBase(Base):
# Too many arguments.
self.assertRaises(TypeError, t.pop, 1, 2, 3)
class UnsignedMappingBase(UnsignedMixin, MappingBase):
pass
def __test_key_or_value_type(self, k, v, to_test, kvtype):
try:
kvtype(to_test)
except Exception as e: # pylint:disable=broad-except
with self.assertRaises(type(e)):
self._makeOne()[k] = v
else:
self._makeOne()[k] = v
def __test_key(self, k):
v = self.getTwoValues()[0]
self.__test_key_or_value_type(k, v, k, self.key_type)
def __test_value(self, v):
k = self.getTwoKeys()[0]
self.__test_key_or_value_type(k, v, v, self.value_type)
def test_assign_key_type_str(self):
self.__test_key('c')
# Assigning a str may or may not work; but querying for
# one will always return a correct answer, not raise
# a TypeError.
def testStringAllowedInContains(self):
self.assertFalse('key' in self._makeOne())
def testStringKeyRaisesKeyErrorWhenMissing(self):
self.assertRaises(KeyError, self._makeOne().__getitem__, 'key')
def testStringKeyReturnsDefaultFromGetWhenMissing(self):
self.assertEqual(self._makeOne().get('key', 42), 42)
def test_assign_key_type_float(self):
self.__test_key(2.5)
def test_assign_key_type_None(self):
self.__test_key(None)
def test_assign_value_type_str(self):
self.__test_value('c')
def test_assign_value_type_float(self):
self.__test_value(2.5)
def test_assign_value_type_None(self):
self.__test_value(None)
def testEmptyFirstBucketReportedByGuido(self):
# This was for Integer keys
from .._compat import xrange
b = self._makeOne()
for i in xrange(29972): # reduce to 29971 and it works
b[i] = i
for i in xrange(30): # reduce to 29 and it works
del b[i]
b[i + 40000] = i
self.assertEqual(b.keys()[0], 30)
def testKeyAndValueOverflow(self):
if self.key_type.get_upper_bound() is None or self.value_type.get_upper_bound() is None:
self.skipTest("Needs bounded key and value")
import struct
from .._compat import PY2
good = set()
b = self._makeOne()
# Some platforms (Windows) use a 32-bit value for long,
# meaning that PyInt_AsLong and such can throw OverflowError
# for values that are in range on most other platforms. And on Python 2,
# PyInt_Check can fail with a TypeError starting at small values
# like 2147483648. So we look for small longs and catch those errors
# even when we think we should be in range.
long_is_32_bit = struct.calcsize('@l') < 8
in_range_errors = (OverflowError, TypeError) if long_is_32_bit else ()
out_of_range_errors = (OverflowError, TypeError) if long_is_32_bit and PY2 else (OverflowError,)
def trial(i):
i = int(i)
__traceback_info__ = i, type(i)
# As key
if i > self.key_type.get_upper_bound():
with self.assertRaises(out_of_range_errors):
b[i] = 0
elif i < self.key_type.get_lower_bound():
with self.assertRaises(out_of_range_errors):
b[i] = 0
else:
try:
b[i] = 0
except in_range_errors:
pass
else:
good.add(i)
self.assertEqual(b[i], 0)
# As value
if i > self.value_type.get_upper_bound():
with self.assertRaises(out_of_range_errors):
b[0] = i
elif i < self.value_type.get_lower_bound():
with self.assertRaises(out_of_range_errors):
b[0] = i
else:
try:
b[0] = i
except in_range_errors:
pass
else:
self.assertEqual(b[0], i)
for i in range(self.key_type.get_upper_bound() - 3,
self.key_type.get_upper_bound() + 3):
class UnsignedValuesMappingBase(UnsignedValuesMixin, MappingBase):
pass
trial(i)
trial(-i)
class UnsignedKeysMappingBase(UnsignedKeysMixin, MappingBase):
pass
if 0 in b:
del b[0]
self.assertEqual(sorted(good), sorted(b))
if not long_is_32_bit:
if self.key_type.get_lower_bound() == 0:
# None of the negative values got in
self.assertEqual(4, len(b))
else:
# 9, not 4 * 2, because of the asymmetry
# of twos complement binary integers
self.assertEqual(9, len(b))
class BTreeTests(MappingBase):
......@@ -1462,15 +1573,6 @@ class BTreeTests(MappingBase):
self.assertEqual(s2, s)
class UnsignedBTreeTests(UnsignedMixin, BTreeTests):
pass
class UnsignedValuesBTreeTests(UnsignedValuesMixin, BTreeTests):
pass
class UnsignedKeysBTreeTests(UnsignedKeysMixin, BTreeTests):
pass
class NormalSetTests(Base):
# Test common to all set types
......@@ -1773,10 +1875,6 @@ class NormalSetTests(Base):
# _p_changed being set depends on whether this is a TreeSet or a plain Set
class UnsignedNormalSetTests(UnsignedMixin, NormalSetTests):
pass
class ExtendedSetTests(NormalSetTests):
def testLen(self):
......@@ -1797,10 +1895,6 @@ class ExtendedSetTests(NormalSetTests):
self.assertEqual(t[x], x)
class UnsignedExtendedSetTests(UnsignedMixin, ExtendedSetTests):
pass
class InternalKeysMappingTest(object):
# There must not be any internal keys not in the BTree
......@@ -1826,13 +1920,19 @@ class InternalKeysMappingTest(object):
tree = conn.root.tree = self._makeOne()
i = 0
# Grow the btree until we have multiple buckets
# Grow the btree until we have multiple buckets.
# (Calling ``__getstate__`` to check the internals is expensive, especially
# with the Python implementation, so only do so when we hit the threshold we expect
# the tree to grow. This makes the difference between a 6s test and a 0.6s test.)
bucket_size = self.key_type.bucket_size_for_value(self.value_type)
tree_size = self.key_type.tree_size
while 1:
i += 1
self.add_key(tree, i)
data = tree.__getstate__()[0]
if len(data) >= 3:
break
if i >= bucket_size:
data = tree.__getstate__()[0]
if len(data) >= 3:
break
transaction.commit()
......@@ -1849,10 +1949,11 @@ class InternalKeysMappingTest(object):
while 1:
i += 1
self.add_key(tree, i)
data = tree.__getstate__()[0]
if data[0].__class__ == tree.__class__:
assert len(data[2].__getstate__()[0]) >= 3
break
if i >= tree_size * bucket_size:
data = tree.__getstate__()[0]
if data[0].__class__ == tree.__class__:
assert len(data[2].__getstate__()[0]) >= 3
break
# Now, delete the internal key and make sure it's really gone
key = data[1]
......@@ -1866,7 +1967,9 @@ class InternalKeysMappingTest(object):
class ModuleTest(object):
# test for presence of generic names in module
prefix = None
prefix = ''
key_type = None
value_type = None
def _getModule(self):
pass
def testNames(self):
......@@ -1874,8 +1977,8 @@ class ModuleTest(object):
for name in names:
klass = getattr(self._getModule(), name)
self.assertEqual(klass.__module__, self._getModule().__name__)
self.assertTrue(klass is getattr(self._getModule(),
self.prefix + name))
self.assertIs(klass, getattr(self._getModule(),
self.prefix + name))
# BBB for zope.app.security ZCML :(
pfx_iter = self.prefix + 'TreeIterator'
klass = getattr(self._getModule(), pfx_iter)
......@@ -1895,14 +1998,25 @@ class ModuleTest(object):
elif 'I' in self.prefix:
self.assertTrue(self._getModule().family is BTrees.family32)
# The weighted* functions require the value type to support unions.
def test_weightedUnion_presence(self):
if self.value_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'weightedUnion'))
else:
self.assertFalse(hasattr(self._getModule(), 'weightedUnion'))
class TypeTest(object):
# tests of various type errors
def test_weightedIntersection_presence(self):
if self.value_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'weightedIntersection'))
else:
self.assertFalse(hasattr(self._getModule(), 'weightedIntersection'))
def testBadTypeRaises(self):
self.assertRaises(TypeError, self._stringraises)
self.assertRaises(TypeError, self._floatraises)
self.assertRaises(TypeError, self._noneraises)
# The multiunion function requires the key type to support unions
def test_multiunion_presence(self):
if self.key_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'multiunion'))
else:
self.assertFalse(hasattr(self._getModule(), 'multiunion'))
class I_SetsBase(object):
......@@ -1911,24 +2025,37 @@ class I_SetsBase(object):
super(I_SetsBase, self).setUp()
_skip_if_pure_py_and_py_test(self)
def _getTargetClass(self):
raise NotImplementedError
def _makeOne(self):
return self._getTargetClass()()
def testBadBadKeyAfterFirst(self):
with self.assertRaises(TypeError):
self._getTargetClass()([1, object()])
t = self._makeOne()
self.assertRaises(TypeError, t.__class__, [1, ''])
self.assertRaises(TypeError, t.update, [1, ''])
with self.assertRaises(TypeError):
t.update([1, object()])
def testNonIntegerInsertRaises(self):
self.assertRaises(TypeError, self._insertstringraises)
self.assertRaises(TypeError, self._insertfloatraises)
self.assertRaises(TypeError, self._insertnoneraises)
def __test_key(self, k):
try:
self.key_type(k)
except Exception as e: # pylint:disable=broad-except
with self.assertRaises(type(e)):
self._makeOne().insert(k)
else:
self._makeOne().insert(k)
def _insertstringraises(self):
self._makeOne().insert('a')
def test_key_type_str(self):
self.__test_key('c')
def _insertfloatraises(self):
self._makeOne().insert(1.4)
def test_key_type_float(self):
self.__test_key(2.5)
def _insertnoneraises(self):
self._makeOne().insert(None)
def test_key_type_None(self):
self.__test_key(None)
LARGEST_32_BITS = 2147483647
......@@ -2624,15 +2751,6 @@ class MappingConflictTestBase(ConflictTestBase):
self._test_merge(base, b1, b2, bm, 'merge conflicting inserts',
should_fail=1)
class UnsignedMappingConflictTestBase(UnsignedMixin, MappingConflictTestBase):
pass
class UnsignedValuesMappingConflictTestBase(UnsignedValuesMixin, MappingConflictTestBase):
pass
class UnsignedKeysMappingConflictTestBase(UnsignedKeysMixin, MappingConflictTestBase):
pass
class SetConflictTestBase(ConflictTestBase):
"Set (as opposed to TreeSet) specific tests."
......@@ -2735,9 +2853,6 @@ class SetConflictTestBase(ConflictTestBase):
self._test_merge(base, b1, b2, bm, 'merge conflicting inserts',
should_fail=1)
class UnsignedSetConflictTestBase(UnsignedMixin, SetConflictTestBase):
pass
## utility functions
def lsubtract(l1, l2):
......
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import makeBuilder
class IFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTree
return IFBTree
class IFBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy
class IFBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucket
return IFBucket
class IFBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucketPy
return IFBucketPy
class IFTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSet
return IFTreeSet
class IFTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSetPy
return IFTreeSetPy
class IFSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSet
return IFSet
class IFSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSetPy
return IFSetPy
class IFBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTree
return IFBTree()
class IFBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()
class _TestIFBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonNumericValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
self._makeOne()[1] = 1
self._makeOne()[1] = 1.0
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestIFBTrees(_TestIFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTree
return IFBTree()
class TestIFBTreesPy(_TestIFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()
class TestIFMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IFBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IFBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IFBTree import IFSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IFBTree import IFTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IFBTree import IFBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IFBTree import IFBTree as mkbtree
return mkbtree(*args)
class TestIFMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IFBTree import IFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IFBTree import IFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IFBTree import IFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IFBTree import IFBTreePy as mkbtree
return mkbtree(*args)
class PureIF(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IFBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IFBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IFBTree import difference
return difference(*args)
def builders(self):
from BTrees.IFBTree import IFBTree
from BTrees.IFBTree import IFBucket
from BTrees.IFBTree import IFTreeSet
from BTrees.IFBTree import IFSet
return IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket)
class PureIFPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IFBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IFBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IFBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IFBTree import IFBTreePy
from BTrees.IFBTree import IFBucketPy
from BTrees.IFBTree import IFTreeSetPy
from BTrees.IFBTree import IFSetPy
return (IFSetPy, IFTreeSetPy,
makeBuilder(IFBTreePy), makeBuilder(IFBucketPy))
class IFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTree
return IFBTree
class IFBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy
class IFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucket
return IFBucket
class IFBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucketPy
return IFBucketPy
class IFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSet
return IFTreeSet
class IFTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSetPy
return IFTreeSetPy
class IFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSet
return IFSet
class IFSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSetPy
return IFSetPy
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
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
class IIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTree
return IIBTree
class IIBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy
class IIBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucket
return IIBucket
class IIBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucketPy
return IIBucketPy
class IITreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSet
return IITreeSet
class IITreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy
class IISetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISet
return IISet
class IISetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISetPy
return IISetPy
class _IIBTreeTestBase(BTreeTests):
def testIIBTreeOverflow(self):
good = set()
b = self._makeOne()
def trial(i):
i = int(i)
try:
b[i] = 0
except OverflowError:
self.assertRaises(OverflowError, b.__setitem__, 0, i)
except TypeError:
self.assertRaises(TypeError, b.__setitem__, 0, i)
else:
good.add(i)
b[0] = i
self.assertEqual(b[0], i)
for i in range((1<<31) - 3, (1<<31) + 3):
trial(i)
trial(-i)
del b[0]
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()
class _TestIIBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._floatraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
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):
def _makeOne(self):
from BTrees.IIBTree import 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):
def _makeOne(self):
from BTrees.IIBTree import IITreeSet
return IITreeSet()
class TestIITreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy()
class PureII(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IIBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IIBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IIBTree import difference
return difference(*args)
def builders(self):
from BTrees.IIBTree import IIBTree
from BTrees.IIBTree import IIBucket
from BTrees.IIBTree import IITreeSet
from BTrees.IIBTree import IISet
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):
def multiunion(self, *args):
from BTrees.IIBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IIBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IIBTree import IISet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IIBTree import IITreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IIBTree import IIBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IIBTree import IIBTree as mkbtree
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):
def weightedUnion(self):
from BTrees.IIBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.IIBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.IIBTree import union
return union
def intersection(self):
from BTrees.IIBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.IIBTree import IIBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.IIBTree import IIBTree
from BTrees.IIBTree import IIBucket
from BTrees.IIBTree import IITreeSet
from BTrees.IIBTree import IISet
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):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTree
return IIBTree
class IIBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBTreePy
return IIBTreePy
class IIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucket
return IIBucket
class IIBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IIBucketPy
return IIBucketPy
class IITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSet
return IITreeSet
class IITreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IITreeSetPy
return IITreeSetPy
class IISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISet
return IISet
class IISetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IIBTree import IISetPy
return IISetPy
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
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TypeTest
from .common import makeBuilder
class IOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTree
return IOBTree
class IOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy
class IOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucket
return IOBucket
class IOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucketPy
return IOBucketPy
class IOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet
class IOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy
class IOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSet
return IOSet
class IOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy
class IOBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTree
return IOBTree()
class IOBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy()
class _TestIOBTreesBase(TypeTest):
def _stringraises(self):
self._makeOne()['c'] = 1
def _floatraises(self):
self._makeOne()[2.5] = 1
def _noneraises(self):
self._makeOne()[None] = 1
def testStringAllowedInContains(self):
self.assertFalse('key' in self._makeOne())
def testStringKeyRaisesKeyErrorWhenMissing(self):
self.assertRaises(KeyError, self._makeOne().__getitem__, 'key')
def testStringKeyReturnsDefaultFromGetWhenMissing(self):
self.assertEqual(self._makeOne().get('key', 42), 42)
class TestIOBTrees(_TestIOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTree
return IOBTree()
class TestIOBTreesPy(_TestIOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy()
class TestIOSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOSet
return IOSet()
class TestIOSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy()
class TestIOTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet()
class TestIOTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy()
class PureIO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IOBTree import difference
return difference(*args)
def builders(self):
from BTrees.IOBTree import IOBTree
from BTrees.IOBTree import IOBucket
from BTrees.IOBTree import IOTreeSet
from BTrees.IOBTree import IOSet
return IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket)
class PureIOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IOBTree import IOBTreePy
from BTrees.IOBTree import IOBucketPy
from BTrees.IOBTree import IOTreeSetPy
from BTrees.IOBTree import IOSetPy
return (IOSetPy, IOTreeSetPy,
makeBuilder(IOBTreePy), makeBuilder(IOBucketPy))
class TestIOMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IOBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IOBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IOBTree import IOSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IOBTree import IOTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IOBTree import IOBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IOBTree import IOBTree as mkbtree
return mkbtree(*args)
class TestIOMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IOBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IOBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IOBTree import IOSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IOBTree import IOTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IOBTree import IOBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IOBTree import IOBTreePy as mkbtree
return mkbtree(*args)
class IOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTree
return IOBTree
class IOBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy
class IOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucket
return IOBucket
class IOBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucketPy
return IOBucketPy
class IOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet
class IOTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy
class IOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSet
return IOSet
class IOSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy
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")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedValuesBTreeTests as BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedValuesMappingBase as MappingBase
from .common import UnsignedValuesMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import UnsignedValuesMixin
from .common import UnsignedError
# pylint:disable=no-name-in-module,arguments-differ
class IUBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBTree
return IUBTree
class IUBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBTreePy
return IUBTreePy
class IUBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBucket
return IUBucket
class IUBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBucketPy
return IUBucketPy
class IUTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUTreeSet
return IUTreeSet
class IUTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUTreeSetPy
return IUTreeSetPy
class IUSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUSet
return IUSet
class IUSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUSetPy
return IUSetPy
class _IUBTreeTestBase(BTreeTests):
def testIUBTreeOverflow(self):
good = set()
b = self._makeOne()
def trial(i):
i = int(i)
try:
b[i] = i
except UnsignedError:
pass
else:
good.add(i)
b[0] = i
self.assertEqual(b[0], i)
for i in range((1<<31) - 3, (1<<31) + 3):
trial(i)
trial(-i)
del b[0]
self.assertEqual(sorted(good), sorted(b))
class IUBTreeTest(_IUBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUBTree
return IUBTree()
class IUBTreeTestPy(_IUBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUBTreePy
return IUBTreePy()
class _TestIUBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._floatraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestIUBTrees(_TestIUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUBTree
return IUBTree()
class TestIUBTreesPy(_TestIUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUBTreePy
return IUBTreePy()
class TestIUSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUSet
return IUSet()
class TestIUSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUSetPy
return IUSetPy()
class TestIUTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUTreeSet
return IUTreeSet()
class TestIUTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IUBTree import IUTreeSetPy
return IUTreeSetPy()
class PureIU(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IUBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IUBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IUBTree import difference
return difference(*args)
def builders(self):
from BTrees.IUBTree import IUBTree
from BTrees.IUBTree import IUBucket
from BTrees.IUBTree import IUTreeSet
from BTrees.IUBTree import IUSet
return IUSet, IUTreeSet, makeBuilder(IUBTree), makeBuilder(IUBucket)
class PureIUPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IUBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IUBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IUBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IUBTree import IUBTreePy
from BTrees.IUBTree import IUBucketPy
from BTrees.IUBTree import IUTreeSetPy
from BTrees.IUBTree import IUSetPy
return (IUSetPy, IUTreeSetPy,
makeBuilder(IUBTreePy), makeBuilder(IUBucketPy))
class TestIUMultiUnion(UnsignedValuesMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IUBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IUBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IUBTree import IUSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IUBTree import IUTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IUBTree import IUBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IUBTree import IUBTree as mkbtree
return mkbtree(*args)
class TestIUMultiUnionPy(UnsignedValuesMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IUBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IUBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IUBTree import IUSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IUBTree import IUTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IUBTree import IUBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IUBTree import IUBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedIU(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.IUBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.IUBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.IUBTree import union
return union
def intersection(self):
from BTrees.IUBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.IUBTree import IUBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.IUBTree import IUBTree
from BTrees.IUBTree import IUBucket
from BTrees.IUBTree import IUTreeSet
from BTrees.IUBTree import IUSet
return IUBucket, IUBTree, itemsToSet(IUSet), itemsToSet(IUTreeSet)
class TestWeightedIUPy(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.IUBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.IUBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.IUBTree import unionPy
return unionPy
def intersection(self):
from BTrees.IUBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.IUBTree import IUBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.IUBTree import IUBTreePy
from BTrees.IUBTree import IUBucketPy
from BTrees.IUBTree import IUTreeSetPy
from BTrees.IUBTree import IUSetPy
return (IUBucketPy, IUBTreePy,
itemsToSet(IUSetPy), itemsToSet(IUTreeSetPy))
class IUBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBTree
return IUBTree
class IUBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBTreePy
return IUBTreePy
class IUBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBucket
return IUBucket
class IUBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUBucketPy
return IUBucketPy
class IUTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUTreeSet
return IUTreeSet
class IUTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUTreeSetPy
return IUTreeSetPy
class IUSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUSet
return IUSet
class IUSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IUBTree import IUSetPy
return IUSetPy
class IUModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IU'
def _getModule(self):
import BTrees
return BTrees.IUBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerUnsignedBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import makeBuilder
class LFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBTree
return LFBTree
class LFBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBTreePy
return LFBTreePy
class LFBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBucket
return LFBucket
class LFBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBucketPy
return LFBucketPy
class LFTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFTreeSet
return LFTreeSet
class LFTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFTreeSetPy
return LFTreeSetPy
class LFSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFSet
return LFSet
class LFSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFSetPy
return LFSetPy
class LFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.LFBTree import LFBTree
return LFBTree()
def getTwoValues(self):
return 0.5, 1.5
class LFBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.LFBTree import LFBTreePy
return LFBTreePy()
def getTwoValues(self):
return 0.5, 1.5
class TestLFMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.LFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.LFBTree import LFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LFBTree import LFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LFBTree import LFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LFBTree import LFBTreePy as mkbtree
return mkbtree(*args)
class TestLFMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.LFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.LFBTree import LFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LFBTree import LFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LFBTree import LFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LFBTree import LFBTreePy as mkbtree
return mkbtree(*args)
class PureLF(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LFBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.LFBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.LFBTree import difference
return difference(*args)
def builders(self):
from BTrees.LFBTree import LFBTree
from BTrees.LFBTree import LFBucket
from BTrees.LFBTree import LFTreeSet
from BTrees.LFBTree import LFSet
return LFSet, LFTreeSet, makeBuilder(LFBTree), makeBuilder(LFBucket)
class PureLFPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LFBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.LFBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.LFBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.LFBTree import LFBTreePy
from BTrees.LFBTree import LFBucketPy
from BTrees.LFBTree import LFTreeSetPy
from BTrees.LFBTree import LFSetPy
return (LFSetPy, LFTreeSetPy,
makeBuilder(LFBTreePy), makeBuilder(LFBucketPy))
class LFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBTree
return LFBTree
class LFBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBTreePy
return LFBTreePy
class LFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBucket
return LFBucket
class LFBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFBucketPy
return LFBucketPy
class LFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFTreeSet
return LFTreeSet
class LFTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFTreeSetPy
return LFTreeSetPy
class LFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFSet
return LFSet
class LFSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LFBTree import LFSetPy
return LFSetPy
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
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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
class LLBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBTree
return LLBTree
class LLBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBTreePy
return LLBTreePy
class LLBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBucket
return LLBucket
class LLBucketTestPy(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBucketPy
return LLBucketPy
class LLTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLTreeSet
return LLTreeSet
class LLTreeSetTestPy(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLTreeSetPy
return LLTreeSetPy
class LLSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLSet
return LLSet
class LLSetTestPy(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLSetPy
return LLSetPy
class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLBTree
return LLBTree()
def getTwoValues(self):
return 1, 2
class LLBTreeTestPy(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLBTreePy
return LLBTreePy()
def getTwoValues(self):
return 1, 2
class TestLLSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLSet
return LLSet()
class TestLLSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLSetPy
return LLSetPy()
class TestLLTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLTreeSet
return LLTreeSet()
class TestLLTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LLBTree import LLTreeSetPy
return LLTreeSetPy()
class PureLL(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LLBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.LLBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.LLBTree import difference
return difference(*args)
def builders(self):
from BTrees.LLBTree import LLBTree
from BTrees.LLBTree import LLBucket
from BTrees.LLBTree import LLTreeSet
from BTrees.LLBTree import LLSet
return LLSet, LLTreeSet, makeBuilder(LLBTree), makeBuilder(LLBucket)
class PureLLPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LLBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.LLBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.LLBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.LLBTree import LLBTreePy
from BTrees.LLBTree import LLBucketPy
from BTrees.LLBTree import LLTreeSetPy
from BTrees.LLBTree import LLSetPy
return (LLSetPy, LLTreeSetPy,
makeBuilder(LLBTreePy), makeBuilder(LLBucketPy))
class TestLLMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LLBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.LLBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.LLBTree import LLSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LLBTree import LLTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LLBTree import LLBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LLBTree import LLBTree as mkbtree
return mkbtree(*args)
class TestLLMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LLBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.LLBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.LLBTree import LLSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LLBTree import LLTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LLBTree import LLBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LLBTree import LLBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedLL(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.LLBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.LLBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.LLBTree import union
return union
def intersection(self):
from BTrees.LLBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.LLBTree import LLBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.LLBTree import LLBTree
from BTrees.LLBTree import LLBucket
from BTrees.LLBTree import LLTreeSet
from BTrees.LLBTree import LLSet
return LLBucket, LLBTree, itemsToSet(LLSet), itemsToSet(LLTreeSet)
class TestWeightedLLPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.LLBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.LLBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.LLBTree import unionPy
return unionPy
def intersection(self):
from BTrees.LLBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.LLBTree import LLBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.LLBTree import LLBTreePy
from BTrees.LLBTree import LLBucketPy
from BTrees.LLBTree import LLTreeSetPy
from BTrees.LLBTree import LLSetPy
return (LLBucketPy, LLBTreePy,
itemsToSet(LLSetPy), itemsToSet(LLTreeSetPy))
class LLBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBTree
return LLBTree
class LLBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBTreePy
return LLBTreePy
class LLBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBucket
return LLBucket
class LLBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLBucketPy
return LLBucketPy
class LLTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLTreeSet
return LLTreeSet
class LLTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLTreeSetPy
return LLTreeSetPy
class LLSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLSet
return LLSet
class LLSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LLBTree import LLSetPy
return LLSetPy
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
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntKeys
from .common import makeBuilder
class LOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBTree
return LOBTree
class LOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBTreePy
return LOBTreePy
class LOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBucket
return LOBucket
class LOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBucketPy
return LOBucketPy
class LOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOTreeSet
return LOTreeSet
class LOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOTreeSetPy
return LOTreeSetPy
class LOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOSet
return LOSet
class LOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOSetPy
return LOSetPy
class LOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOBTree
return LOBTree()
class LOBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOBTreePy
return LOBTreePy()
class TestLOSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOSet
return LOSet()
class TestLOSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOSetPy
return LOSetPy()
class TestLOTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOTreeSet
return LOTreeSet()
class TestLOTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LOBTree import LOTreeSetPy
return LOTreeSetPy()
class TestLOMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LOBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.LOBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.LOBTree import LOSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LOBTree import LOTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LOBTree import LOBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LOBTree import LOBTree as mkbtree
return mkbtree(*args)
class TestLOMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LOBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.LOBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.LOBTree import LOSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LOBTree import LOTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LOBTree import LOBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LOBTree import LOBTreePy as mkbtree
return mkbtree(*args)
class PureLO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.LOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.LOBTree import difference
return difference(*args)
def builders(self):
from BTrees.LOBTree import LOBTree
from BTrees.LOBTree import LOBucket
from BTrees.LOBTree import LOTreeSet
from BTrees.LOBTree import LOSet
return LOSet, LOTreeSet, makeBuilder(LOBTree), makeBuilder(LOBucket)
class PureLOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.LOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.LOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.LOBTree import LOBTreePy
from BTrees.LOBTree import LOBucketPy
from BTrees.LOBTree import LOTreeSetPy
from BTrees.LOBTree import LOSetPy
return (LOSetPy, LOTreeSetPy,
makeBuilder(LOBTreePy), makeBuilder(LOBucketPy))
class LOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBTree
return LOBTree
class LOBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBTreePy
return LOBTreePy
class LOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBucket
return LOBucket
class LOBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOBucketPy
return LOBucketPy
class LOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOTreeSet
return LOTreeSet
class LOTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOTreeSetPy
return LOTreeSetPy
class LOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOSet
return LOSet
class LOSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LOBTree import LOSetPy
return LOSetPy
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")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedValuesBTreeTests as BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedValuesMappingBase as MappingBase
from .common import UnsignedValuesMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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
# pylint:disable=no-name-in-module,arguments-differ
class LQBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBTree
return LQBTree
class LQBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBTreePy
return LQBTreePy
class LQBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBucket
return LQBucket
class LQBucketTestPy(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBucketPy
return LQBucketPy
class LQTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQTreeSet
return LQTreeSet
class LQTreeSetTestPy(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQTreeSetPy
return LQTreeSetPy
class LQSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQSet
return LQSet
class LQSetTestPy(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQSetPy
return LQSetPy
class LQBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQBTree
return LQBTree()
def getTwoValues(self):
return 1, 2
class LQBTreeTestPy(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQBTreePy
return LQBTreePy()
def getTwoValues(self):
return 1, 2
class TestLQSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQSet
return LQSet()
class TestLQSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQSetPy
return LQSetPy()
class TestLQTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQTreeSet
return LQTreeSet()
class TestLQTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.LQBTree import LQTreeSetPy
return LQTreeSetPy()
class PureLQ(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LQBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.LQBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.LQBTree import difference
return difference(*args)
def builders(self):
from BTrees.LQBTree import LQBTree
from BTrees.LQBTree import LQBucket
from BTrees.LQBTree import LQTreeSet
from BTrees.LQBTree import LQSet
return LQSet, LQTreeSet, makeBuilder(LQBTree), makeBuilder(LQBucket)
class PureLQPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.LQBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.LQBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.LQBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.LQBTree import LQBTreePy
from BTrees.LQBTree import LQBucketPy
from BTrees.LQBTree import LQTreeSetPy
from BTrees.LQBTree import LQSetPy
return (LQSetPy, LQTreeSetPy,
makeBuilder(LQBTreePy), makeBuilder(LQBucketPy))
class TestLQMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LQBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.LQBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.LQBTree import LQSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LQBTree import LQTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LQBTree import LQBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LQBTree import LQBTree as mkbtree
return mkbtree(*args)
class TestLQMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.LQBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.LQBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.LQBTree import LQSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.LQBTree import LQTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.LQBTree import LQBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.LQBTree import LQBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedLQ(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.LQBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.LQBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.LQBTree import union
return union
def intersection(self):
from BTrees.LQBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.LQBTree import LQBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.LQBTree import LQBTree
from BTrees.LQBTree import LQBucket
from BTrees.LQBTree import LQTreeSet
from BTrees.LQBTree import LQSet
return LQBucket, LQBTree, itemsToSet(LQSet), itemsToSet(LQTreeSet)
class TestWeightedLQPy(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.LQBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.LQBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.LQBTree import unionPy
return unionPy
def intersection(self):
from BTrees.LQBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.LQBTree import LQBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.LQBTree import LQBTreePy
from BTrees.LQBTree import LQBucketPy
from BTrees.LQBTree import LQTreeSetPy
from BTrees.LQBTree import LQSetPy
return (LQBucketPy, LQBTreePy,
itemsToSet(LQSetPy), itemsToSet(LQTreeSetPy))
class LQBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBTree
return LQBTree
class LQBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBTreePy
return LQBTreePy
class LQBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBucket
return LQBucket
class LQBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQBucketPy
return LQBucketPy
class LQTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQTreeSet
return LQTreeSet
class LQTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQTreeSetPy
return LQTreeSetPy
class LQSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQSet
return LQSet
class LQSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.LQBTree import LQSetPy
return LQSetPy
class LQModuleTest(ModuleTest, unittest.TestCase):
prefix = 'LQ'
def _getModule(self):
import BTrees
return BTrees.LQBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerUnsignedBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TypeTest
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
class OIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBTree
return OIBTree
class OIBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBTreePy
return OIBTreePy
class OIBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBucket
return OIBucket
class OIBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBucketPy
return OIBucketPy
class OITreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OITreeSet
return OITreeSet
class OITreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OITreeSetPy
return OITreeSetPy
class OISetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OISet
return OISet
class OISetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OISetPy
return OISetPy
class OIBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTree
return OIBTree()
class OIBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTreePy
return OIBTreePy()
class _TestOIBTreesBase(TypeTest):
def _stringraises(self):
self._makeOne()[1] = 'c'
def _floatraises(self):
self._makeOne()[1] = 1.4
def _noneraises(self):
self._makeOne()[1] = None
def testEmptyFirstBucketReportedByGuido(self):
from .._compat import xrange
b = self._makeOne()
for i in xrange(29972): # reduce to 29971 and it works
b[i] = i
for i in xrange(30): # reduce to 29 and it works
del b[i]
b[i+40000] = i
self.assertEqual(b.keys()[0], 30)
class TestOIBTrees(_TestOIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTree
return OIBTree()
class TestOIBTreesPy(_TestOIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.OIBTree import OIBTreePy
return OIBTreePy()
class PureOI(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OIBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.OIBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.OIBTree import difference
return difference(*args)
def builders(self):
from BTrees.OIBTree import OIBTree
from BTrees.OIBTree import OIBucket
from BTrees.OIBTree import OITreeSet
from BTrees.OIBTree import OISet
return OISet, OITreeSet, makeBuilder(OIBTree), makeBuilder(OIBucket)
class PureOIPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OIBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.OIBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.OIBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.OIBTree import OIBTreePy
from BTrees.OIBTree import OIBucketPy
from BTrees.OIBTree import OITreeSetPy
from BTrees.OIBTree import OISetPy
return (OISetPy, OITreeSetPy,
makeBuilder(OIBTreePy), makeBuilder(OIBucketPy))
class TestWeightedOI(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OIBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.OIBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.OIBTree import union
return union
def intersection(self):
from BTrees.OIBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.OIBTree import OIBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OIBTree import OIBTree
from BTrees.OIBTree import OIBucket
from BTrees.OIBTree import OITreeSet
from BTrees.OIBTree import OISet
return OIBucket, OIBTree, itemsToSet(OISet), itemsToSet(OITreeSet)
class TestWeightedOIPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OIBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.OIBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.OIBTree import unionPy
return unionPy
def intersection(self):
from BTrees.OIBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.OIBTree import OIBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OIBTree import OIBTreePy
from BTrees.OIBTree import OIBucketPy
from BTrees.OIBTree import OITreeSetPy
from BTrees.OIBTree import OISetPy
return (OIBucketPy, OIBTreePy,
itemsToSet(OISetPy), itemsToSet(OITreeSetPy))
class OIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBucket
return OIBucket
class OIBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBucketPy
return OIBucketPy
class OISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OISet
return OISet
class OISetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OISetPy
return OISetPy
class OIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBTree
return OIBTree
class OIBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OIBTreePy
return OIBTreePy
class OITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OITreeSet
return OITreeSet
class OITreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OIBTree import OITreeSetPy
return OITreeSetPy
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")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import _skip_on_32_bits
class OLBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBTree
return OLBTree
class OLBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBTreePy
return OLBTreePy
class OLBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBucket
return OLBucket
class OLBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBucketPy
return OLBucketPy
class OLTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLTreeSet
return OLTreeSet
class OLTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLTreeSetPy
return OLTreeSetPy
class OLSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLSet
return OLSet
class OLSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLSetPy
return OLSetPy
class OLBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OLBTree import OLBTree
return OLBTree()
def getTwoKeys(self):
return "abc", "def"
@_skip_on_32_bits
def test_extremes(self):
from BTrees.tests.common import SMALLEST_64_BITS
from BTrees.tests.common import SMALLEST_POSITIVE_65_BITS
from BTrees.tests.common import LARGEST_64_BITS
from BTrees.tests.common import LARGEST_NEGATIVE_65_BITS
btree = self._makeOne()
btree['ZERO'] = 0
btree['SMALLEST_64_BITS'] = SMALLEST_64_BITS
btree['LARGEST_64_BITS'] = LARGEST_64_BITS
self.assertRaises((ValueError, OverflowError), btree.__setitem__,
'SMALLEST_POSITIVE_65_BITS', SMALLEST_POSITIVE_65_BITS)
self.assertRaises((ValueError, OverflowError), btree.__setitem__,
'LARGEST_NEGATIVE_65_BITS', LARGEST_NEGATIVE_65_BITS)
class OLBTreePyTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OLBTree import OLBTreePy
return OLBTreePy()
def getTwoKeys(self):
return "abc", "def"
class PureOL(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OLBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.OLBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.OLBTree import difference
return difference(*args)
def builders(self):
from BTrees.OLBTree import OLBTree
from BTrees.OLBTree import OLBucket
from BTrees.OLBTree import OLTreeSet
from BTrees.OLBTree import OLSet
return OLSet, OLTreeSet, makeBuilder(OLBTree), makeBuilder(OLBucket)
class PureOLPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OLBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.OLBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.OLBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.OLBTree import OLBTreePy
from BTrees.OLBTree import OLBucketPy
from BTrees.OLBTree import OLTreeSetPy
from BTrees.OLBTree import OLSetPy
return (OLSetPy, OLTreeSetPy,
makeBuilder(OLBTreePy), makeBuilder(OLBucketPy))
class TestWeightedOL(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OLBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.OLBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.OLBTree import union
return union
def intersection(self):
from BTrees.OLBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.OLBTree import OLBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OLBTree import OLBTree
from BTrees.OLBTree import OLBucket
from BTrees.OLBTree import OLTreeSet
from BTrees.OLBTree import OLSet
return OLBucket, OLBTree, itemsToSet(OLSet), itemsToSet(OLTreeSet)
class TestWeightedOLPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OLBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.OLBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.OLBTree import unionPy
return unionPy
def intersection(self):
from BTrees.OLBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.OLBTree import OLBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OLBTree import OLBTreePy
from BTrees.OLBTree import OLBucketPy
from BTrees.OLBTree import OLTreeSetPy
from BTrees.OLBTree import OLSetPy
return (OLBucketPy, OLBTreePy,
itemsToSet(OLSetPy), itemsToSet(OLTreeSetPy))
class OLBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBucket
return OLBucket
class OLBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBucketPy
return OLBucketPy
class OLSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLSet
return OLSet
class OLSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLSetPy
return OLSetPy
class OLBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBTree
return OLBTree
class OLBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLBTreePy
return OLBTreePy
class OLTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLTreeSet
return OLTreeSet
class OLTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OLBTree import OLTreeSetPy
return OLTreeSetPy
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")
......@@ -11,83 +11,12 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import unittest
from BTrees import OOBTree
from .common import _skip_under_Py3k
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import NormalSetTests
from .common import SetResult
from .common import SetConflictTestBase
from .common import makeBuilder
from ._test_builder import update_module
class OOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBTreePy
return OOBTreePy
class OOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBTree
return OOBTree
class OOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBucket
return OOBucket
class OOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBucketPy
return OOBucketPy
class OOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOTreeSet
return OOTreeSet
class OOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOTreeSetPy
return OOTreeSetPy
class OOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOSet
return OOSet
class OOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOSetPy
return OOSetPy
class OOBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self, *args):
from BTrees.OOBTree import OOBTree
return OOBTree(*args)
class OOBTreeTest(BTreeTests):
def test_byValue(self):
ITEMS = [(y, x) for x, y in enumerate('abcdefghijklmnopqrstuvwxyz')]
......@@ -110,8 +39,6 @@ class OOBTreeTest(BTreeTests, unittest.TestCase):
class C(object):
pass
self.assertRaises(TypeError, lambda : t.__setitem__(C(), 1))
with self.assertRaises(TypeError) as raising:
t[C()] = 1
......@@ -151,7 +78,7 @@ class OOBTreeTest(BTreeTests, unittest.TestCase):
for i in range(999): # Make sure we multiple buckets
t[i] = i*i
t[None] = -1
for i in range(-99,0): # Make sure we multiple buckets
for i in range(-99, 0): # Make sure we multiple buckets
t[i] = i*i
self.assertEqual(list(t), [None] + list(range(-99, 999)))
self.assertEqual(list(t.values()),
......@@ -221,151 +148,4 @@ class OOBTreeTest(BTreeTests, unittest.TestCase):
self.assertEqual(list(t), [])
class OOBTreePyTest(OOBTreeTest):
#
# Right now, we can't match the C extension's test / prohibition of the
# default 'object' comparison semantics.
#class OOBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self, *args):
from BTrees.OOBTree import OOBTreePy
return OOBTreePy(*args)
class PureOO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.OOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.OOBTree import difference
return difference(*args)
def builders(self):
from BTrees.OOBTree import OOBTree
from BTrees.OOBTree import OOBucket
from BTrees.OOBTree import OOTreeSet
from BTrees.OOBTree import OOSet
return OOSet, OOTreeSet, makeBuilder(OOBTree), makeBuilder(OOBucket)
class PureOOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.OOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.OOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.OOBTree import OOBTreePy
from BTrees.OOBTree import OOBucketPy
from BTrees.OOBTree import OOTreeSetPy
from BTrees.OOBTree import OOSetPy
return (OOSetPy, OOTreeSetPy,
makeBuilder(OOBTreePy), makeBuilder(OOBucketPy))
class OOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBucket
return OOBucket
class OOBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBucketPy
return OOBucketPy
class OOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOSet
return OOSet
class OOSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOSetPy
return OOSetPy
class OOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBTree
return OOBTree
class OOBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOBTreePy
return OOBTreePy
class OOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOTreeSet
return OOTreeSet
class OOTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OOBTree import OOTreeSetPy
return OOTreeSetPy
class OOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OO'
def _getModule(self):
import BTrees
return BTrees.OOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.OOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("OOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.OOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("OOBTree shouldn't have weightedIntersection")
def test_multiunion_not_present(self):
try:
from BTrees.OOBTree import multiunion
except ImportError:
pass
else:
self.fail("OOBTree shouldn't have multiunion")
update_module(globals(), OOBTree, btree_tests_base=OOBTreeTest)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedValuesBTreeTests as BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import UnsignedValuesMappingBase as MappingBase
from .common import UnsignedValuesMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import _skip_on_32_bits
from .common import UnsignedValuesMixin
# pylint:disable=no-name-in-module,arguments-differ
class OQBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBTree
return OQBTree
class OQBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBTreePy
return OQBTreePy
class OQBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBucket
return OQBucket
class OQBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBucketPy
return OQBucketPy
class OQTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQTreeSet
return OQTreeSet
class OQTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQTreeSetPy
return OQTreeSetPy
class OQSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQSet
return OQSet
class OQSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQSetPy
return OQSetPy
class OQBTreeTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OQBTree import OQBTree
return OQBTree()
def getTwoKeys(self):
return "abc", "def"
@_skip_on_32_bits
def test_extremes(self):
from BTrees.tests.common import SMALLEST_POSITIVE_65_BITS
from BTrees.tests.common import LARGEST_64_BITS
from BTrees.tests.common import LARGEST_NEGATIVE_65_BITS
btree = self._makeOne()
btree['ZERO'] = 0
btree['SMALLEST_64_BITS'] = 0
btree['LARGEST_64_BITS'] = LARGEST_64_BITS
btree['SMALLEST_POSITIVE_65_BITS'] = SMALLEST_POSITIVE_65_BITS
with self.assertRaises((ValueError, OverflowError)):
btree['TOO_BIG'] = 2**65
self.assertRaises((ValueError, OverflowError), btree.__setitem__,
'LARGEST_NEGATIVE_65_BITS', LARGEST_NEGATIVE_65_BITS)
class OQBTreePyTest(BTreeTests, TestLongIntValues, unittest.TestCase):
def _makeOne(self):
from BTrees.OQBTree import OQBTreePy
return OQBTreePy()
def getTwoKeys(self):
return "abc", "def"
class PureOQ(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OQBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.OQBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.OQBTree import difference
return difference(*args)
def builders(self):
from BTrees.OQBTree import OQBTree
from BTrees.OQBTree import OQBucket
from BTrees.OQBTree import OQTreeSet
from BTrees.OQBTree import OQSet
return OQSet, OQTreeSet, makeBuilder(OQBTree), makeBuilder(OQBucket)
class PureOQPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OQBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.OQBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.OQBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.OQBTree import OQBTreePy
from BTrees.OQBTree import OQBucketPy
from BTrees.OQBTree import OQTreeSetPy
from BTrees.OQBTree import OQSetPy
return (OQSetPy, OQTreeSetPy,
makeBuilder(OQBTreePy), makeBuilder(OQBucketPy))
class TestWeightedOQ(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OQBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.OQBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.OQBTree import union
return union
def intersection(self):
from BTrees.OQBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.OQBTree import OQBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OQBTree import OQBTree
from BTrees.OQBTree import OQBucket
from BTrees.OQBTree import OQTreeSet
from BTrees.OQBTree import OQSet
return OQBucket, OQBTree, itemsToSet(OQSet), itemsToSet(OQTreeSet)
class TestWeightedOQPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OQBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.OQBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.OQBTree import unionPy
return unionPy
def intersection(self):
from BTrees.OQBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.OQBTree import OQBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OQBTree import OQBTreePy
from BTrees.OQBTree import OQBucketPy
from BTrees.OQBTree import OQTreeSetPy
from BTrees.OQBTree import OQSetPy
return (OQBucketPy, OQBTreePy,
itemsToSet(OQSetPy), itemsToSet(OQTreeSetPy))
class OQBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBucket
return OQBucket
class OQBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBucketPy
return OQBucketPy
class OQSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQSet
return OQSet
class OQSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQSetPy
return OQSetPy
class OQBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBTree
return OQBTree
class OQBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQBTreePy
return OQBTreePy
class OQTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQTreeSet
return OQTreeSet
class OQTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OQBTree import OQTreeSetPy
return OQTreeSetPy
class OQModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OQ'
def _getModule(self):
import BTrees
return BTrees.OQBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectUnsignedBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OQBTree import multiunion
except ImportError:
pass
else:
self.fail("OQBTree shouldn't have multiunion")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedValuesBTreeTests as BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import UnsignedValuesMappingBase as MappingBase
from .common import UnsignedValuesMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
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 .common import UnsignedValuesMixin
class OUBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBTree
return OUBTree
class OUBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBTreePy
return OUBTreePy
class OUBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBucket
return OUBucket
class OUBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBucketPy
return OUBucketPy
class OUTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUTreeSet
return OUTreeSet
class OUTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUTreeSetPy
return OUTreeSetPy
class OUSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUSet
return OUSet
class OUSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUSetPy
return OUSetPy
class OUBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTree
return OUBTree()
class OUBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTreePy
return OUBTreePy()
class _TestOUBTreesBase(TypeTest):
def _stringraises(self):
self._makeOne()[1] = 'c'
def _floatraises(self):
self._makeOne()[1] = 1.4
def _noneraises(self):
self._makeOne()[1] = None
def testEmptyFirstBucketReportedByGuido(self):
from .._compat import xrange
b = self._makeOne()
for i in xrange(29972): # reduce to 29971 and it works
b[i] = i
for i in xrange(30): # reduce to 29 and it works
del b[i]
b[i+40000] = i
self.assertEqual(b.keys()[0], 30)
class TestOUBTrees(_TestOUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTree
return OUBTree()
class TestOUBTreesPy(_TestOUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.OUBTree import OUBTreePy
return OUBTreePy()
class PureOU(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OUBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.OUBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.OUBTree import difference
return difference(*args)
def builders(self):
from BTrees.OUBTree import OUBTree
from BTrees.OUBTree import OUBucket
from BTrees.OUBTree import OUTreeSet
from BTrees.OUBTree import OUSet
return OUSet, OUTreeSet, makeBuilder(OUBTree), makeBuilder(OUBucket)
class PureOUPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.OUBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.OUBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.OUBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.OUBTree import OUBTreePy
from BTrees.OUBTree import OUBucketPy
from BTrees.OUBTree import OUTreeSetPy
from BTrees.OUBTree import OUSetPy
return (OUSetPy, OUTreeSetPy,
makeBuilder(OUBTreePy), makeBuilder(OUBucketPy))
class TestWeightedOU(UnsignedValuesMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OUBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.OUBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.OUBTree import union
return union
def intersection(self):
from BTrees.OUBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.OUBTree import OUBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OUBTree import OUBTree
from BTrees.OUBTree import OUBucket
from BTrees.OUBTree import OUTreeSet
from BTrees.OUBTree import OUSet
return OUBucket, OUBTree, itemsToSet(OUSet), itemsToSet(OUTreeSet)
class TestWeightedOUPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.OUBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.OUBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.OUBTree import unionPy
return unionPy
def intersection(self):
from BTrees.OUBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.OUBTree import OUBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.OUBTree import OUBTreePy
from BTrees.OUBTree import OUBucketPy
from BTrees.OUBTree import OUTreeSetPy
from BTrees.OUBTree import OUSetPy
return (OUBucketPy, OUBTreePy,
itemsToSet(OUSetPy), itemsToSet(OUTreeSetPy))
class OUBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBucket
return OUBucket
class OUBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBucketPy
return OUBucketPy
class OUSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUSet
return OUSet
class OUSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUSetPy
return OUSetPy
class OUBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBTree
return OUBTree
class OUBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUBTreePy
return OUBTreePy
class OUTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUTreeSet
return OUTreeSet
class OUTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.OUBTree import OUTreeSetPy
return OUTreeSetPy
class OUModuleTest(ModuleTest, unittest.TestCase):
prefix = 'OU'
def _getModule(self):
import BTrees
return BTrees.OUBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IObjectUnsignedBTreeModule
def test_multiunion_not_present(self):
try:
from BTrees.OUBTree import multiunion
except ImportError:
pass
else:
self.fail("OUBTree shouldn't have multiunion")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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
# pylint: disable=no-name-in-module,arguments-differ
class QFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBTree
return QFBTree
class QFBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBTreePy
return QFBTreePy
class QFBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBucket
return QFBucket
class QFBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBucketPy
return QFBucketPy
class QFTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFTreeSet
return QFTreeSet
class QFTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFTreeSetPy
return QFTreeSetPy
class QFSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFSet
return QFSet
class QFSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFSetPy
return QFSetPy
class QFBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.QFBTree import QFBTree
return QFBTree()
def getTwoValues(self):
return 0.5, 1.5
class QFBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.QFBTree import QFBTreePy
return QFBTreePy()
def getTwoValues(self):
return 0.5, 1.5
class TestQFMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.QFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.QFBTree import QFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QFBTree import QFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QFBTree import QFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QFBTree import QFBTreePy as mkbtree
return mkbtree(*args)
class TestQFMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.QFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.QFBTree import QFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QFBTree import QFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QFBTree import QFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QFBTree import QFBTreePy as mkbtree
return mkbtree(*args)
class PureQF(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QFBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.QFBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.QFBTree import difference
return difference(*args)
def builders(self):
from BTrees.QFBTree import QFBTree
from BTrees.QFBTree import QFBucket
from BTrees.QFBTree import QFTreeSet
from BTrees.QFBTree import QFSet
return QFSet, QFTreeSet, makeBuilder(QFBTree), makeBuilder(QFBucket)
class PureQFPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QFBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.QFBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.QFBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.QFBTree import QFBTreePy
from BTrees.QFBTree import QFBucketPy
from BTrees.QFBTree import QFTreeSetPy
from BTrees.QFBTree import QFSetPy
return (QFSetPy, QFTreeSetPy,
makeBuilder(QFBTreePy), makeBuilder(QFBucketPy))
class QFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBTree
return QFBTree
class QFBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBTreePy
return QFBTreePy
class QFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBucket
return QFBucket
class QFBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFBucketPy
return QFBucketPy
class QFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFTreeSet
return QFTreeSet
class QFTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFTreeSetPy
return QFTreeSetPy
class QFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFSet
return QFSet
class QFSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QFBTree import QFSetPy
return QFSetPy
class QFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'QF'
def _getModule(self):
import BTrees
return BTrees.QFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedFloatBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import I_SetsBase
from .common import TestLongIntValues
from .common import Weighted
from .common import itemsToSet
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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
# pylint: disable=no-name-in-module,arguments-differ
class QLBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBTree
return QLBTree
class QLBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBTreePy
return QLBTreePy
class QLBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBucket
return QLBucket
class QLBucketTestPy(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBucketPy
return QLBucketPy
class QLTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLTreeSet
return QLTreeSet
class QLTreeSetTestPy(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLTreeSetPy
return QLTreeSetPy
class QLSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLSet
return QLSet
class QLSetTestPy(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLSetPy
return QLSetPy
class QLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLBTree
return QLBTree()
def getTwoValues(self):
return 1, 2
class QLBTreeTestPy(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLBTreePy
return QLBTreePy()
def getTwoValues(self):
return 1, 2
class TestQLSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLSet
return QLSet()
class TestQLSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLSetPy
return QLSetPy()
class TestQLTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLTreeSet
return QLTreeSet()
class TestQLTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QLBTree import QLTreeSetPy
return QLTreeSetPy()
class PureQL(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QLBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.QLBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.QLBTree import difference
return difference(*args)
def builders(self):
from BTrees.QLBTree import QLBTree
from BTrees.QLBTree import QLBucket
from BTrees.QLBTree import QLTreeSet
from BTrees.QLBTree import QLSet
return QLSet, QLTreeSet, makeBuilder(QLBTree), makeBuilder(QLBucket)
class PureQLPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QLBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.QLBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.QLBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.QLBTree import QLBTreePy
from BTrees.QLBTree import QLBucketPy
from BTrees.QLBTree import QLTreeSetPy
from BTrees.QLBTree import QLSetPy
return (QLSetPy, QLTreeSetPy,
makeBuilder(QLBTreePy), makeBuilder(QLBucketPy))
class TestQLMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QLBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.QLBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.QLBTree import QLSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QLBTree import QLTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QLBTree import QLBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QLBTree import QLBTree as mkbtree
return mkbtree(*args)
class TestQLMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QLBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.QLBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.QLBTree import QLSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QLBTree import QLTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QLBTree import QLBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QLBTree import QLBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedQL(UnsignedKeysMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.QLBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.QLBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.QLBTree import union
return union
def intersection(self):
from BTrees.QLBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.QLBTree import QLBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.QLBTree import QLBTree
from BTrees.QLBTree import QLBucket
from BTrees.QLBTree import QLTreeSet
from BTrees.QLBTree import QLSet
return QLBucket, QLBTree, itemsToSet(QLSet), itemsToSet(QLTreeSet)
class TestWeightedQLPy(UnsignedKeysMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.QLBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.QLBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.QLBTree import unionPy
return unionPy
def intersection(self):
from BTrees.QLBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.QLBTree import QLBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.QLBTree import QLBTreePy
from BTrees.QLBTree import QLBucketPy
from BTrees.QLBTree import QLTreeSetPy
from BTrees.QLBTree import QLSetPy
return (QLBucketPy, QLBTreePy,
itemsToSet(QLSetPy), itemsToSet(QLTreeSetPy))
class QLBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBTree
return QLBTree
class QLBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBTreePy
return QLBTreePy
class QLBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBucket
return QLBucket
class QLBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLBucketPy
return QLBucketPy
class QLTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLTreeSet
return QLTreeSet
class QLTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLTreeSetPy
return QLTreeSetPy
class QLSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLSet
return QLSet
class QLSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QLBTree import QLSetPy
return QLSetPy
class QLModuleTest(ModuleTest, unittest.TestCase):
prefix = 'QL'
def _getModule(self):
import BTrees
return BTrees.QLBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedIntegerBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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
# pylint:disable=no-name-in-module,arguments-differ
class QOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBTree
return QOBTree
class QOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBTreePy
return QOBTreePy
class QOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBucket
return QOBucket
class QOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBucketPy
return QOBucketPy
class QOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOTreeSet
return QOTreeSet
class QOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOTreeSetPy
return QOTreeSetPy
class QOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOSet
return QOSet
class QOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOSetPy
return QOSetPy
class QOBTreeTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOBTree
return QOBTree()
class QOBTreePyTest(BTreeTests, TestLongIntKeys, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOBTreePy
return QOBTreePy()
class TestQOSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOSet
return QOSet()
class TestQOSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOSetPy
return QOSetPy()
class TestQOTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOTreeSet
return QOTreeSet()
class TestQOTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QOBTree import QOTreeSetPy
return QOTreeSetPy()
class TestQOMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QOBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.QOBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.QOBTree import QOSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QOBTree import QOTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QOBTree import QOBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QOBTree import QOBTree as mkbtree
return mkbtree(*args)
class TestQOMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QOBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.QOBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.QOBTree import QOSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QOBTree import QOTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QOBTree import QOBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QOBTree import QOBTreePy as mkbtree
return mkbtree(*args)
class PureQO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.QOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.QOBTree import difference
return difference(*args)
def builders(self):
from BTrees.QOBTree import QOBTree
from BTrees.QOBTree import QOBucket
from BTrees.QOBTree import QOTreeSet
from BTrees.QOBTree import QOSet
return QOSet, QOTreeSet, makeBuilder(QOBTree), makeBuilder(QOBucket)
class PureQOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.QOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.QOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.QOBTree import QOBTreePy
from BTrees.QOBTree import QOBucketPy
from BTrees.QOBTree import QOTreeSetPy
from BTrees.QOBTree import QOSetPy
return (QOSetPy, QOTreeSetPy,
makeBuilder(QOBTreePy), makeBuilder(QOBucketPy))
class QOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBTree
return QOBTree
class QOBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBTreePy
return QOBTreePy
class QOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBucket
return QOBucket
class QOBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOBucketPy
return QOBucketPy
class QOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOTreeSet
return QOTreeSet
class QOTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOTreeSetPy
return QOTreeSetPy
class QOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOSet
return QOSet
class QOSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QOBTree import QOSetPy
return QOSetPy
class QOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'QO'
def _getModule(self):
import BTrees
return BTrees.QOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.QOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("QOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.QOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("QOBTree shouldn't have weightedIntersection")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedMappingBase as MappingBase
from .common import UnsignedMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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 UnsignedMixin
# pylint:disable=no-name-in-module,arguments-differ
class QQBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBTree
return QQBTree
class QQBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBTreePy
return QQBTreePy
class QQBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBucket
return QQBucket
class QQBucketTestPy(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBucketPy
return QQBucketPy
class QQTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQTreeSet
return QQTreeSet
class QQTreeSetTestPy(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQTreeSetPy
return QQTreeSetPy
class QQSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQSet
return QQSet
class QQSetTestPy(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQSetPy
return QQSetPy
class QQBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQBTree
return QQBTree()
def getTwoValues(self):
return 1, 2
class QQBTreeTestPy(BTreeTests, TestLongIntKeys, TestLongIntValues,
unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQBTreePy
return QQBTreePy()
def getTwoValues(self):
return 1, 2
class TestQQSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQSet
return QQSet()
class TestQQSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQSetPy
return QQSetPy()
class TestQQTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQTreeSet
return QQTreeSet()
class TestQQTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.QQBTree import QQTreeSetPy
return QQTreeSetPy()
class PureQQ(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QQBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.QQBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.QQBTree import difference
return difference(*args)
def builders(self):
from BTrees.QQBTree import QQBTree
from BTrees.QQBTree import QQBucket
from BTrees.QQBTree import QQTreeSet
from BTrees.QQBTree import QQSet
return QQSet, QQTreeSet, makeBuilder(QQBTree), makeBuilder(QQBucket)
class PureQQPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.QQBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.QQBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.QQBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.QQBTree import QQBTreePy
from BTrees.QQBTree import QQBucketPy
from BTrees.QQBTree import QQTreeSetPy
from BTrees.QQBTree import QQSetPy
return (QQSetPy, QQTreeSetPy,
makeBuilder(QQBTreePy), makeBuilder(QQBucketPy))
class TestQQMultiUnion(UnsignedMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QQBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.QQBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.QQBTree import QQSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QQBTree import QQTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QQBTree import QQBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QQBTree import QQBTree as mkbtree
return mkbtree(*args)
class TestQQMultiUnionPy(UnsignedMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.QQBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.QQBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.QQBTree import QQSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.QQBTree import QQTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.QQBTree import QQBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.QQBTree import QQBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedQQ(UnsignedMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.QQBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.QQBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.QQBTree import union
return union
def intersection(self):
from BTrees.QQBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.QQBTree import QQBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.QQBTree import QQBTree
from BTrees.QQBTree import QQBucket
from BTrees.QQBTree import QQTreeSet
from BTrees.QQBTree import QQSet
return QQBucket, QQBTree, itemsToSet(QQSet), itemsToSet(QQTreeSet)
class TestWeightedQQPy(UnsignedMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.QQBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.QQBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.QQBTree import unionPy
return unionPy
def intersection(self):
from BTrees.QQBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.QQBTree import QQBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.QQBTree import QQBTreePy
from BTrees.QQBTree import QQBucketPy
from BTrees.QQBTree import QQTreeSetPy
from BTrees.QQBTree import QQSetPy
return (QQBucketPy, QQBTreePy,
itemsToSet(QQSetPy), itemsToSet(QQTreeSetPy))
class QQBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBTree
return QQBTree
class QQBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBTreePy
return QQBTreePy
class QQBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBucket
return QQBucket
class QQBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQBucketPy
return QQBucketPy
class QQTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQTreeSet
return QQTreeSet
class QQTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQTreeSetPy
return QQTreeSetPy
class QQSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQSet
return QQSet
class QQSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.QQBTree import QQSetPy
return QQSetPy
class QQModuleTest(ModuleTest, unittest.TestCase):
prefix = 'QQ'
def _getModule(self):
import BTrees
return BTrees.QQBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedUnsignedBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import UnsignedNormalSetTests as NormalSetTests
from .common import UnsignedSetConflictTestBase as SetConflictTestBase
from .common import SetResult
from .common import makeBuilder
from .common import UnsignedKeysMixin
# pylint:disable=no-name-in-module,arguments-differ
class UFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBTree
return UFBTree
class UFBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy
class UFBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBucket
return UFBucket
class UFBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBucketPy
return UFBucketPy
class UFTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFTreeSet
return UFTreeSet
class UFTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFTreeSetPy
return UFTreeSetPy
class UFSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFSet
return UFSet
class UFSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFSetPy
return UFSetPy
class UFBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.UFBTree import UFBTree
return UFBTree()
class UFBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy()
class _TestUFBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonNumericValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
self._makeOne()[1] = 1
self._makeOne()[1] = 1.0
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestUFBTrees(_TestUFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UFBTree import UFBTree
return UFBTree()
class TestUFBTreesPy(_TestUFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy()
class TestUFMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UFBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.UFBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.UFBTree import UFSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UFBTree import UFTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UFBTree import UFBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UFBTree import UFBTree as mkbtree
return mkbtree(*args)
class TestUFMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.UFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.UFBTree import UFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UFBTree import UFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UFBTree import UFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UFBTree import UFBTreePy as mkbtree
return mkbtree(*args)
class PureUF(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UFBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.UFBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.UFBTree import difference
return difference(*args)
def builders(self):
from BTrees.UFBTree import UFBTree
from BTrees.UFBTree import UFBucket
from BTrees.UFBTree import UFTreeSet
from BTrees.UFBTree import UFSet
return UFSet, UFTreeSet, makeBuilder(UFBTree), makeBuilder(UFBucket)
class PureUFPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UFBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.UFBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.UFBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.UFBTree import UFBTreePy
from BTrees.UFBTree import UFBucketPy
from BTrees.UFBTree import UFTreeSetPy
from BTrees.UFBTree import UFSetPy
return (UFSetPy, UFTreeSetPy,
makeBuilder(UFBTreePy), makeBuilder(UFBucketPy))
class UFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBTree
return UFBTree
class UFBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBTreePy
return UFBTreePy
class UFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBucket
return UFBucket
class UFBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFBucketPy
return UFBucketPy
class UFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFTreeSet
return UFTreeSet
class UFTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFTreeSetPy
return UFTreeSetPy
class UFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFSet
return UFSet
class UFSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UFBTree import UFSetPy
return UFSetPy
class UFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'UF'
def _getModule(self):
import BTrees
return BTrees.UFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedFloatBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import UnsignedNormalSetTests as NormalSetTests
from .common import UnsignedSetConflictTestBase as SetConflictTestBase
from .common import SetResult
from .common import Weighted
from .common import itemsToSet
from .common import makeBuilder
from .common import UnsignedKeysMixin
from .common import UnsignedError
# pylint:disable=no-name-in-module,arguments-differ
class UIBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBTree
return UIBTree
class UIBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBTreePy
return UIBTreePy
class UIBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBucket
return UIBucket
class UIBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBucketPy
return UIBucketPy
class UITreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UITreeSet
return UITreeSet
class UITreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UITreeSetPy
return UITreeSetPy
class UISetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UISet
return UISet
class UISetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UISetPy
return UISetPy
class _UIBTreeTestBase(BTreeTests):
def testUIBTreeOverflow(self):
good = set()
b = self._makeOne()
def trial(i):
i = int(i)
try:
b[i] = 0
except (UnsignedError):
__traceback_info__ = i
if i > 2 ** 31:
with self.assertRaises(UnsignedError):
b[0] = i
else:
good.add(i)
if i < 2 ** 31:
b[0] = i
self.assertEqual(b[0], i)
else:
with self.assertRaises(UnsignedError):
b[0] = i
for i in range((1<<31) - 3, (1<<31) + 3):
trial(i)
trial(-i)
del b[0]
self.assertEqual(sorted(good), sorted(b))
class UIBTreeTest(_UIBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UIBTree
return UIBTree()
class UIBTreeTestPy(_UIBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UIBTreePy
return UIBTreePy()
class _TestUIBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._floatraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestUIBTrees(_TestUIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UIBTree
return UIBTree()
class TestUIBTreesPy(_TestUIBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UIBTreePy
return UIBTreePy()
class TestUISets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UISet
return UISet()
class TestUISetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UISetPy
return UISetPy()
class TestUITreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UITreeSet
return UITreeSet()
class TestUITreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UIBTree import UITreeSetPy
return UITreeSetPy()
class PureUI(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UIBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.UIBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.UIBTree import difference
return difference(*args)
def builders(self):
from BTrees.UIBTree import UIBTree
from BTrees.UIBTree import UIBucket
from BTrees.UIBTree import UITreeSet
from BTrees.UIBTree import UISet
return UISet, UITreeSet, makeBuilder(UIBTree), makeBuilder(UIBucket)
class PureUIPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UIBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.UIBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.UIBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.UIBTree import UIBTreePy
from BTrees.UIBTree import UIBucketPy
from BTrees.UIBTree import UITreeSetPy
from BTrees.UIBTree import UISetPy
return (UISetPy, UITreeSetPy,
makeBuilder(UIBTreePy), makeBuilder(UIBucketPy))
class TestUIMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UIBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.UIBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.UIBTree import UISet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UIBTree import UITreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UIBTree import UIBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UIBTree import UIBTree as mkbtree
return mkbtree(*args)
class TestUIMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UIBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.UIBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.UIBTree import UISetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UIBTree import UITreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UIBTree import UIBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UIBTree import UIBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedUI(UnsignedKeysMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.UIBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.UIBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.UIBTree import union
return union
def intersection(self):
from BTrees.UIBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.UIBTree import UIBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.UIBTree import UIBTree
from BTrees.UIBTree import UIBucket
from BTrees.UIBTree import UITreeSet
from BTrees.UIBTree import UISet
return UIBucket, UIBTree, itemsToSet(UISet), itemsToSet(UITreeSet)
class TestWeightedUIPy(Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.UIBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.UIBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.UIBTree import unionPy
return unionPy
def intersection(self):
from BTrees.UIBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.UIBTree import UIBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.UIBTree import UIBTreePy
from BTrees.UIBTree import UIBucketPy
from BTrees.UIBTree import UITreeSetPy
from BTrees.UIBTree import UISetPy
return (UIBucketPy, UIBTreePy,
itemsToSet(UISetPy), itemsToSet(UITreeSetPy))
class UIBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBTree
return UIBTree
class UIBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBTreePy
return UIBTreePy
class UIBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBucket
return UIBucket
class UIBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UIBucketPy
return UIBucketPy
class UITreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UITreeSet
return UITreeSet
class UITreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UITreeSetPy
return UITreeSetPy
class UISetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UISet
return UISet
class UISetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UIBTree import UISetPy
return UISetPy
class UIModuleTest(ModuleTest, unittest.TestCase):
prefix = 'UI'
def _getModule(self):
import BTrees
return BTrees.UIBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedIntegerBTreeModule
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedKeysBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedKeysMappingBase as MappingBase
from .common import UnsignedKeysMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import UnsignedNormalSetTests as NormalSetTests
from .common import UnsignedSetConflictTestBase as SetConflictTestBase
from .common import SetResult
from .common import TypeTest
from .common import TestLongIntKeys
from .common import makeBuilder
from .common import UnsignedKeysMixin
from .common import UnsignedError
# pylint:disable=no-name-in-module,arguments-differ
class UOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBTree
return UOBTree
class UOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBTreePy
return UOBTreePy
class UOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBucket
return UOBucket
class UOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBucketPy
return UOBucketPy
class UOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOTreeSet
return UOTreeSet
class UOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOTreeSetPy
return UOTreeSetPy
class UOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOSet
return UOSet
class UOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOSetPy
return UOSetPy
class UOBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOBTree
return UOBTree()
class UOBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOBTreePy
return UOBTreePy()
class _TestUOBTreesBase(TypeTest):
def _stringraises(self):
self._makeOne()['c'] = 1
def _floatraises(self):
self._makeOne()[2.5] = 1
def _noneraises(self):
self._makeOne()[None] = 1
def testStringAllowedInContains(self):
self.assertFalse('key' in self._makeOne())
def testStringKeyRaisesKeyErrorWhenMissing(self):
self.assertRaises(KeyError, self._makeOne().__getitem__, 'key')
def testStringKeyReturnsDefaultFromGetWhenMissing(self):
self.assertEqual(self._makeOne().get('key', 42), 42)
class TestUOBTrees(_TestUOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOBTree
return UOBTree()
class TestUOBTreesPy(_TestUOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOBTreePy
return UOBTreePy()
class TestUOSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOSet
return UOSet()
class TestUOSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOSetPy
return UOSetPy()
class TestUOTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOTreeSet
return UOTreeSet()
class TestUOTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UOBTree import UOTreeSetPy
return UOTreeSetPy()
class PureUO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.UOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.UOBTree import difference
return difference(*args)
def builders(self):
from BTrees.UOBTree import UOBTree
from BTrees.UOBTree import UOBucket
from BTrees.UOBTree import UOTreeSet
from BTrees.UOBTree import UOSet
return UOSet, UOTreeSet, makeBuilder(UOBTree), makeBuilder(UOBucket)
class PureUOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.UOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.UOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.UOBTree import UOBTreePy
from BTrees.UOBTree import UOBucketPy
from BTrees.UOBTree import UOTreeSetPy
from BTrees.UOBTree import UOSetPy
return (UOSetPy, UOTreeSetPy,
makeBuilder(UOBTreePy), makeBuilder(UOBucketPy))
class TestUOMultiUnion(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UOBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.UOBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.UOBTree import UOSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UOBTree import UOTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UOBTree import UOBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UOBTree import UOBTree as mkbtree
return mkbtree(*args)
class TestUOMultiUnionPy(UnsignedKeysMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UOBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.UOBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.UOBTree import UOSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UOBTree import UOTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UOBTree import UOBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UOBTree import UOBTreePy as mkbtree
return mkbtree(*args)
class UOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBTree
return UOBTree
class UOBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBTreePy
return UOBTreePy
class UOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBucket
return UOBucket
class UOBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOBucketPy
return UOBucketPy
class UOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOTreeSet
return UOTreeSet
class UOTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOTreeSetPy
return UOTreeSetPy
class UOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOSet
return UOSet
class UOSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UOBTree import UOSetPy
return UOSetPy
class UOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'UO'
def _getModule(self):
import BTrees
return BTrees.UOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.UOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("UOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.UOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("UOBTree shouldn't have weightedIntersection")
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
import unittest
from .common import UnsignedBTreeTests as BTreeTests
from .common import UnsignedExtendedSetTests as ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import UnsignedMappingBase as MappingBase
from .common import UnsignedMappingConflictTestBase as MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
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 UnsignedMixin
from .common import UnsignedError
class UUBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBTree
return UUBTree
class UUBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBTreePy
return UUBTreePy
class UUBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBucket
return UUBucket
class UUBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBucketPy
return UUBucketPy
class UUTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUTreeSet
return UUTreeSet
class UUTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUTreeSetPy
return UUTreeSetPy
class UUSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUSet
return UUSet
class UUSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUSetPy
return UUSetPy
class _UUBTreeTestBase(BTreeTests):
def testUUBTreeOverflow(self):
good = set()
b = self._makeOne()
def trial(i):
i = int(i)
try:
b[i] = 0
except UnsignedError:
with self.assertRaises(UnsignedError):
b[0] = i
else:
good.add(i)
b[0] = i
self.assertEqual(b[0], i)
for i in range((1<<31) - 3, (1<<31) + 3):
__traceback_info__ = i
trial(i)
trial(-i)
del b[0]
self.assertEqual(sorted(good), sorted(b))
class UUBTreeTest(_UUBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUBTree
return UUBTree()
class UUBTreeTestPy(_UUBTreeTestBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUBTreePy
return UUBTreePy()
class _TestUUBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._floatraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestUUBTrees(_TestUUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUBTree
return UUBTree()
class TestUUBTreesPy(_TestUUBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUBTreePy
return UUBTreePy()
class TestUUSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUSet
return UUSet()
class TestUUSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUSetPy
return UUSetPy()
class TestUUTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUTreeSet
return UUTreeSet()
class TestUUTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.UUBTree import UUTreeSetPy
return UUTreeSetPy()
class PureUU(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UUBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.UUBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.UUBTree import difference
return difference(*args)
def builders(self):
from BTrees.UUBTree import UUBTree
from BTrees.UUBTree import UUBucket
from BTrees.UUBTree import UUTreeSet
from BTrees.UUBTree import UUSet
return UUSet, UUTreeSet, makeBuilder(UUBTree), makeBuilder(UUBucket)
class PureUUPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.UUBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.UUBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.UUBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.UUBTree import UUBTreePy
from BTrees.UUBTree import UUBucketPy
from BTrees.UUBTree import UUTreeSetPy
from BTrees.UUBTree import UUSetPy
return (UUSetPy, UUTreeSetPy,
makeBuilder(UUBTreePy), makeBuilder(UUBucketPy))
class TestUUMultiUnion(UnsignedMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UUBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.UUBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.UUBTree import UUSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UUBTree import UUTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UUBTree import UUBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UUBTree import UUBTree as mkbtree
return mkbtree(*args)
class TestUUMultiUnionPy(UnsignedMixin, MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.UUBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.UUBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.UUBTree import UUSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.UUBTree import UUTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.UUBTree import UUBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.UUBTree import UUBTreePy as mkbtree
return mkbtree(*args)
class TestWeightedUU(UnsignedMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.UUBTree import weightedUnion
return weightedUnion
def weightedIntersection(self):
from BTrees.UUBTree import weightedIntersection
return weightedIntersection
def union(self):
from BTrees.UUBTree import union
return union
def intersection(self):
from BTrees.UUBTree import intersection
return intersection
def mkbucket(self, *args):
from BTrees.UUBTree import UUBucket as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.UUBTree import UUBTree
from BTrees.UUBTree import UUBucket
from BTrees.UUBTree import UUTreeSet
from BTrees.UUBTree import UUSet
return UUBucket, UUBTree, itemsToSet(UUSet), itemsToSet(UUTreeSet)
class TestWeightedUUPy(UnsignedMixin, Weighted, unittest.TestCase):
def weightedUnion(self):
from BTrees.UUBTree import weightedUnionPy
return weightedUnionPy
def weightedIntersection(self):
from BTrees.UUBTree import weightedIntersectionPy
return weightedIntersectionPy
def union(self):
from BTrees.UUBTree import unionPy
return unionPy
def intersection(self):
from BTrees.UUBTree import intersectionPy
return intersectionPy
def mkbucket(self, *args):
from BTrees.UUBTree import UUBucketPy as mkbucket
return mkbucket(*args)
def builders(self):
from BTrees.UUBTree import UUBTreePy
from BTrees.UUBTree import UUBucketPy
from BTrees.UUBTree import UUTreeSetPy
from BTrees.UUBTree import UUSetPy
return (UUBucketPy, UUBTreePy,
itemsToSet(UUSetPy), itemsToSet(UUTreeSetPy))
class UUBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBTree
return UUBTree
class UUBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBTreePy
return UUBTreePy
class UUBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBucket
return UUBucket
class UUBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUBucketPy
return UUBucketPy
class UUTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUTreeSet
return UUTreeSet
class UUTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUTreeSetPy
return UUTreeSetPy
class UUSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUSet
return UUSet
class UUSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.UUBTree import UUSetPy
return UUSetPy
class UUModuleTest(ModuleTest, unittest.TestCase):
prefix = 'UU'
def _getModule(self):
import BTrees
return BTrees.UUBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IUnsignedUnsignedBTreeModule
......@@ -426,9 +426,9 @@ class BucketTests(unittest.TestCase):
return Bucket
def _makeOne(self):
from .._datatypes import O
class _Bucket(self._getTargetClass()):
def _to_key(self, x):
return x
_to_key = O()
def _to_value(self, x):
return x
return _Bucket()
......@@ -1465,11 +1465,14 @@ class Test_Tree(unittest.TestCase):
def _makeOne(self, items=None):
from .._base import Bucket
from .._datatypes import O
from .._datatypes import Any
class _Bucket(Bucket):
def _to_key(self, k):
return k
_to_key = O()
class _Test(self._getTargetClass()):
_to_key = _to_value = lambda self, x: x
_to_key = O()
_to_value = Any()
_bucket_type = _Bucket
max_leaf_size = 10
max_internal_size = 15
......@@ -2903,86 +2906,6 @@ class Test_multiunion(unittest.TestCase, _SetObBase):
class Test_helpers(unittest.TestCase):
def test_to_ob(self):
from BTrees._base import to_ob
faux_self = object()
for thing in "abc", 0, 1.3, (), frozenset((1, 2)), object():
self.assertTrue(to_ob(faux_self, thing) is thing)
def test_to_int_w_int(self):
from BTrees._base import to_int
faux_self = object()
self.assertEqual(to_int(faux_self, 3), 3)
def test_to_int_w_long_in_range(self):
from BTrees._base import to_int
faux_self = object()
try:
self.assertEqual(to_int(faux_self, long(3)), 3)
except NameError: #Python3
pass
def test_to_int_w_overflow(self):
from BTrees._base import to_int
faux_self = object()
self.assertRaises(TypeError, to_int, faux_self, 2**64)
def test_to_int_w_invalid(self):
from BTrees._base import to_int
faux_self = object()
self.assertRaises(TypeError, to_int, faux_self, ())
def test_to_float_w_float(self):
from BTrees._base import to_float
faux_self = object()
self.assertEqual(to_float(faux_self, 3.14159), 3.14159)
def test_to_float_w_int(self):
from BTrees._base import to_float
faux_self = object()
self.assertEqual(to_float(faux_self, 3), 3.0)
def test_to_float_w_invalid(self):
from BTrees._base import to_float
faux_self = object()
self.assertRaises(TypeError, to_float, faux_self, ())
def test_to_long_w_int(self):
from BTrees._base import to_long
faux_self = object()
self.assertEqual(to_long(faux_self, 3), 3)
def test_to_long_w_long_in_range(self):
from BTrees._base import to_long
faux_self = object()
try:
self.assertEqual(to_long(faux_self, long(3)), 3)
except NameError: #Python3
pass
def test_to_long_w_overflow(self):
from BTrees._base import to_long
faux_self = object()
self.assertRaises(OverflowError, to_long, faux_self, 2**64)
def test_to_long_w_invalid(self):
from BTrees._base import to_long
faux_self = object()
self.assertRaises(TypeError, to_long, faux_self, ())
def test_to_bytes_w_ok(self):
from BTrees._base import to_bytes
faux_self = object()
conv = to_bytes(3)
self.assertEqual(conv(faux_self, b'abc'), b'abc')
def test_to_bytes_w_invalid_length(self):
from BTrees._base import to_bytes
faux_self = object()
conv = to_bytes(3)
self.assertRaises(TypeError, conv, faux_self, b'ab')
self.assertRaises(TypeError, conv, faux_self, b'abcd')
def test_MERGE(self):
from BTrees._base import MERGE
faux_self = object()
......
##############################################################################
#
# Copyright 2012 Zope Foundation 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.
#
##############################################################################
import unittest
from BTrees import _datatypes
to_ob = _datatypes.Any()
to_int = _datatypes.I()
to_float = _datatypes.F()
to_long = _datatypes.L()
to_bytes = _datatypes.Bytes
class TestDatatypes(unittest.TestCase):
def test_to_ob(self):
for thing in "abc", 0, 1.3, (), frozenset((1, 2)), object():
self.assertTrue(to_ob(thing) is thing)
def test_to_int_w_int(self):
self.assertEqual(to_int(3), 3)
def test_to_int_w_long_in_range(self):
try:
self.assertEqual(to_int(long(3)), 3)
except NameError: #Python3
pass
def test_to_int_w_overflow(self):
self.assertRaises(OverflowError, to_int, 2**64)
def test_to_int_w_invalid(self):
self.assertRaises(TypeError, to_int, ())
def test_to_float_w_float(self):
self.assertEqual(to_float(3.14159), 3.14159)
def test_to_float_w_int(self):
self.assertEqual(to_float(3), 3.0)
def test_to_float_w_invalid(self):
self.assertRaises(TypeError, to_float, ())
def test_to_long_w_int(self):
self.assertEqual(to_long(3), 3)
def test_to_long_w_long_in_range(self):
try:
self.assertEqual(to_long(long(3)), 3)
except NameError: #Python3
pass
def test_to_long_w_overflow(self):
self.assertRaises(OverflowError, to_long, 2**64)
def test_to_long_w_invalid(self):
self.assertRaises(TypeError, to_long, ())
def test_to_bytes_w_ok(self):
conv = to_bytes(3)
self.assertEqual(conv(b'abc'), b'abc')
def test_to_bytes_w_invalid_length(self):
conv = to_bytes(3)
self.assertRaises(TypeError, conv, b'ab')
self.assertRaises(TypeError, conv, b'abcd')
......@@ -405,9 +405,9 @@ class Test_check(unittest.TestCase):
def _makeTree(fill):
from BTrees.OOBTree import OOBTree
from BTrees.OOBTree import _BUCKET_SIZE
from BTrees.OOBTree import OOBTreePy
tree = OOBTree()
if fill:
for i in range(_BUCKET_SIZE + 1):
for i in range(OOBTreePy.max_leaf_size + 1):
tree[i] = 2*i
return tree
##############################################################################
#
# Copyright (c) 2020 Zope Foundation 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
#
##############################################################################
"""
This module dynamically creates test modules and suites for
all expected BTree families that do not have their own test file on disk.
"""
import unittest
import importlib
import sys
import types
from BTrees import _FAMILIES
from ._test_builder import update_module
# If there is no .py file on disk, create the module in memory.
# This is helpful during early development. However, it
# doesn't work with zope-testrunner's ``-m`` filter.
_suite = unittest.TestSuite()
for family in _FAMILIES:
mod_qname = "BTrees.tests.test_" + family + 'BTree'
try:
importlib.import_module(mod_qname)
except ImportError:
btree = importlib.import_module("BTrees." + family + 'BTree')
mod = types.ModuleType(mod_qname)
update_module(vars(mod), btree)
sys.modules[mod_qname] = mod
globals()[mod_qname.split('.', 1)[1]] = mod
_suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(mod))
def test_suite():
return _suite
......@@ -43,3 +43,23 @@ def oid_repr(oid):
return b''.join(chunks)
else:
return repr(oid)
class Lazy(object):
"""
A simple version of ``Lazy`` from ``zope.cachedescriptors``
"""
__slots__ = ('func',)
def __init__(self, func):
self.func = func
def __get__(self, inst, class_):
if inst is None:
return self
func = self.func
value = func(inst)
inst.__dict__[func.__name__] = value
return value
......@@ -18,6 +18,10 @@
64-bit variants.
- Make the Bucket types consistent with the BTree types as updated in
versions 4.3.2: Querying for keys with default comparisons or that
are not integers no longer raises ``TypeError``.
4.6.1 (2019-11-07)
==================
......
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