Skip to content

Commit

Permalink
Fix stats tests. Need random2.
Browse files Browse the repository at this point in the history
  • Loading branch information
alga committed Mar 13, 2013
1 parent 4d9871f commit 366414a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -71,7 +71,7 @@ def emit(self, record):
suite.addTest(mod.test_suite())
return suite

tests_require = ['zope.testing', 'manuel']
tests_require = ['zope.testing', 'manuel', 'random2']

long_description = (
open('README.txt').read()
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/scripts/cache_simul.py
Expand Up @@ -154,7 +154,7 @@ def main(args=None):
code & 0x80,
code & 0x7e)
# And pass it to the simulation.
this_interval = int(ts)/interval_step
this_interval = int(ts) // interval_step
if this_interval != last_interval:
if last_interval is not None:
interval_sim.report()
Expand Down
8 changes: 3 additions & 5 deletions src/ZEO/scripts/cache_stats.py
Expand Up @@ -298,8 +298,7 @@ def dumpbysize(bysize, how, how2):
print()
print("Unique sizes %s: %s" % (how, addcommas(len(bysize))))
print("%10s %6s %6s" % ("size", "objs", how2))
sizes = bysize.keys()
sizes.sort()
sizes = sorted(bysize.keys())
for size in sizes:
loads = 0
for n in six.itervalues(bysize[size]):
Expand Down Expand Up @@ -348,15 +347,14 @@ def histogram(d):
bins = {}
for v in six.itervalues(d):
bins[v] = bins.get(v, 0) + 1
L = bins.items()
L.sort()
L = sorted(bins.items())
return L

def U64(s):
return struct.unpack(">Q", s)[0]

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)
else:
return repr(oid)
Expand Down
4 changes: 2 additions & 2 deletions src/ZEO/tests/test_cache.py
Expand Up @@ -424,7 +424,7 @@ def thread_safe():
>>> for i in range(100):
... 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)
>>> stop = False
>>> read_failure = None
Expand Down Expand Up @@ -512,7 +512,7 @@ def cache_trace_analysis():
>>> time.time = lambda : now
>>> os.environ["ZEO_CACHE_TRACE"] = 'yes'
>>> import random
>>> import random2 as random
>>> random = random.Random(42)
>>> history = []
>>> serial = 1
Expand Down

0 comments on commit 366414a

Please sign in to comment.