[Checkins] SVN: BTrees/branches/pure_python/ Coverage.
Tres Seaver
cvs-admin at zope.org
Tue Dec 4 21:49:45 UTC 2012
Log message for revision 128521:
Coverage.
Changed:
_U BTrees/branches/pure_python/
U BTrees/branches/pure_python/BTrees/_base.py
U BTrees/branches/pure_python/BTrees/tests/test__base.py
-=-
Modified: BTrees/branches/pure_python/BTrees/_base.py
===================================================================
--- BTrees/branches/pure_python/BTrees/_base.py 2012-12-04 21:49:44 UTC (rev 128520)
+++ BTrees/branches/pure_python/BTrees/_base.py 2012-12-04 21:49:45 UTC (rev 128521)
@@ -1344,7 +1344,8 @@
int_types = int, long
def to_int(self, v):
try:
- if not unpack("i", pack("i", v))[0] == v:
+ # XXX Python 2.6 doesn't truncate, it spews a warning.
+ if not unpack("i", pack("i", v))[0] == v: #pragma NO COVER
raise TypeError('32-bit integer expected')
except (struct_error,
OverflowError, #PyPy
Modified: BTrees/branches/pure_python/BTrees/tests/test__base.py
===================================================================
--- BTrees/branches/pure_python/BTrees/tests/test__base.py 2012-12-04 21:49:44 UTC (rev 128520)
+++ BTrees/branches/pure_python/BTrees/tests/test__base.py 2012-12-04 21:49:45 UTC (rev 128521)
@@ -2699,7 +2699,9 @@
self.assertEqual(weight, 1)
self.assertEqual(list(result), [1, 2, 3, 4])
+ #TODO: test non-default weights
+
class Test_weightedIntersection(unittest.TestCase, _SetObBase):
def _callFUT(self, *args, **kw):
@@ -2770,7 +2772,9 @@
self.assertEqual(weight, 2)
self.assertEqual(list(result), [1])
+ #TODO: test non-default weights
+
class Test_multiunion(unittest.TestCase, _SetObBase):
def _callFUT(self, *args, **kw):
@@ -2794,6 +2798,34 @@
self.assertEqual(list(result), [1, 2])
+class Test_converters(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):
+ import sys
+ from BTrees._base import to_int
+ faux_self = object()
+ self.assertRaises(TypeError, to_int, faux_self, sys.maxint + 1)
+
+
class _Cache(object):
def __init__(self):
self._mru = []
More information about the checkins
mailing list