Commit 366414ae authored by Albertas Agejevas's avatar Albertas Agejevas

Fix stats tests. Need random2.

parent 4d9871f6
...@@ -71,7 +71,7 @@ def alltests(): ...@@ -71,7 +71,7 @@ def alltests():
suite.addTest(mod.test_suite()) suite.addTest(mod.test_suite())
return suite return suite
tests_require = ['zope.testing', 'manuel'] tests_require = ['zope.testing', 'manuel', 'random2']
long_description = ( long_description = (
open('README.txt').read() open('README.txt').read()
......
...@@ -154,7 +154,7 @@ def main(args=None): ...@@ -154,7 +154,7 @@ def main(args=None):
code & 0x80, code & 0x80,
code & 0x7e) code & 0x7e)
# And pass it to the simulation. # And pass it to the simulation.
this_interval = int(ts)/interval_step this_interval = int(ts) // interval_step
if this_interval != last_interval: if this_interval != last_interval:
if last_interval is not None: if last_interval is not None:
interval_sim.report() interval_sim.report()
......
...@@ -298,8 +298,7 @@ def dumpbysize(bysize, how, how2): ...@@ -298,8 +298,7 @@ def dumpbysize(bysize, how, how2):
print() print()
print("Unique sizes %s: %s" % (how, addcommas(len(bysize)))) print("Unique sizes %s: %s" % (how, addcommas(len(bysize))))
print("%10s %6s %6s" % ("size", "objs", how2)) print("%10s %6s %6s" % ("size", "objs", how2))
sizes = bysize.keys() sizes = sorted(bysize.keys())
sizes.sort()
for size in sizes: for size in sizes:
loads = 0 loads = 0
for n in six.itervalues(bysize[size]): for n in six.itervalues(bysize[size]):
...@@ -348,15 +347,14 @@ def histogram(d): ...@@ -348,15 +347,14 @@ def histogram(d):
bins = {} bins = {}
for v in six.itervalues(d): for v in six.itervalues(d):
bins[v] = bins.get(v, 0) + 1 bins[v] = bins.get(v, 0) + 1
L = bins.items() L = sorted(bins.items())
L.sort()
return L return L
def U64(s): def U64(s):
return struct.unpack(">Q", s)[0] return struct.unpack(">Q", s)[0]
def oid_repr(oid): def oid_repr(oid):
if isinstance(oid, str) and len(oid) == 8: if isinstance(oid, six.binary_type) and len(oid) == 8:
return '%16x' % U64(oid) return '%16x' % U64(oid)
else: else:
return repr(oid) return repr(oid)
......
...@@ -424,7 +424,7 @@ def thread_safe(): ...@@ -424,7 +424,7 @@ def thread_safe():
>>> for i in range(100): >>> for i in range(100):
... cache.store(ZODB.utils.p64(i), ZODB.utils.p64(1), None, b'0') ... cache.store(ZODB.utils.p64(i), ZODB.utils.p64(1), None, b'0')
>>> import random, sys, threading >>> import random2 as random, sys, threading
>>> random = random.Random(0) >>> random = random.Random(0)
>>> stop = False >>> stop = False
>>> read_failure = None >>> read_failure = None
...@@ -512,7 +512,7 @@ Check to make sure the cache analysis scripts work. ...@@ -512,7 +512,7 @@ Check to make sure the cache analysis scripts work.
>>> time.time = lambda : now >>> time.time = lambda : now
>>> os.environ["ZEO_CACHE_TRACE"] = 'yes' >>> os.environ["ZEO_CACHE_TRACE"] = 'yes'
>>> import random >>> import random2 as random
>>> random = random.Random(42) >>> random = random.Random(42)
>>> history = [] >>> history = []
>>> serial = 1 >>> serial = 1
......
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