[Checkins] SVN: persistent/trunk/persistent/ Coverage.
Tres Seaver
cvs-admin at zope.org
Mon May 14 23:22:52 UTC 2012
Log message for revision 125882:
Coverage.
Zap fossil timestamp-manipulation functionss: they now live in
'persistent.timestamp'.
Changed:
U persistent/trunk/persistent/pyPersistence.py
U persistent/trunk/persistent/tests/test_pyPersistence.py
-=-
Modified: persistent/trunk/persistent/pyPersistence.py
===================================================================
--- persistent/trunk/persistent/pyPersistence.py 2012-05-14 23:22:44 UTC (rev 125881)
+++ persistent/trunk/persistent/pyPersistence.py 2012-05-14 23:22:48 UTC (rev 125882)
@@ -12,7 +12,6 @@
#
##############################################################################
from copy_reg import __newobj__
-import struct
import sys
from zope.interface import implements
@@ -25,17 +24,12 @@
from persistent.interfaces import STICKY
from persistent.timestamp import TimeStamp
-if sys.version_info < (2, 6,):
- OID_TYPE = SERIAL_TYPE = str
-else:
- OID_TYPE = SERIAL_TYPE = bytes
+OID_TYPE = SERIAL_TYPE = bytes
def _makeOctets(s):
- if sys.version_info < (2, 6,):
- return str(s)
if sys.version_info < (3,):
return bytes(s)
- return bytes(s, 'ascii')
+ return bytes(s, 'ascii') #pragma NO COVER
_INITIAL_SERIAL = _makeOctets('\x00' * 8)
@@ -55,25 +49,7 @@
'__setstate__'
)
-_SCONV = 60.0 / (1<<16) / (1<<16)
-def makeTimestamp(year, month, day, hour, minute, second):
- a = (((year - 1900) * 12 + month - 1) * 31 + day - 1)
- a = (a * 24 + hour) * 60 + minute
- b = int(second / _SCONV)
- return struct.pack('>II', a, b)
-
-def parseTimestamp(octets):
- a, b = struct.unpack('>II', octets)
- minute = a % 60
- hour = a // 60 % 24
- day = a // (60 * 24) % 31 + 1
- month = a // (60 * 24 * 31) % 12 + 1
- year = a // (60 * 24 * 31 * 12) + 1900
- second = b * _SCONV
- return (year, month, day, hour, minute, second)
-
-
class Persistent(object):
""" Pure Python implmentation of Persistent base class
"""
Modified: persistent/trunk/persistent/tests/test_pyPersistence.py
===================================================================
--- persistent/trunk/persistent/tests/test_pyPersistence.py 2012-05-14 23:22:44 UTC (rev 125881)
+++ persistent/trunk/persistent/tests/test_pyPersistence.py 2012-05-14 23:22:48 UTC (rev 125882)
@@ -74,6 +74,12 @@
inst._p_jar = new_jar
self.assertRaises(ValueError, _test)
+ def test_assign_p_jar_w_invalid_jar(self):
+ inst = self._makeOne()
+ def _test():
+ inst._p_jar = object()
+ self.assertRaises(ValueError, _test)
+
def test_assign_p_jar_w_valid_jar(self):
jar = self._makeJar()
inst = self._makeOne()
@@ -474,11 +480,21 @@
inst._p_estimated_size = -1
self.assertRaises(ValueError, _test)
- def test_assign_p_estimated_size(self):
+ def test_assign_p_estimated_size_small(self):
inst = self._makeOne()
inst._p_estimated_size = 123
self.assertEqual(inst._p_estimated_size, 128)
+ def test_assign_p_estimated_size_just_over_threshold(self):
+ inst = self._makeOne()
+ inst._p_estimated_size = 1073741697
+ self.assertEqual(inst._p_estimated_size, 16777215 * 64)
+
+ def test_assign_p_estimated_size_bigger(self):
+ inst = self._makeOne()
+ inst._p_estimated_size = 1073741697 * 1024
+ self.assertEqual(inst._p_estimated_size, 16777215 * 64)
+
def test___getattribute___p__names(self):
NAMES = ['_p_jar',
'_p_oid',
More information about the checkins
mailing list