[svn r58576] * fix test to not rely on time.time() resolution

* strike some superflous __init__ code

--HG--
branch : trunk
This commit is contained in:
hpk 2008-10-02 18:19:04 +02:00
parent af86caf712
commit 4b1c2eec3b
2 changed files with 6 additions and 3 deletions

View File

@ -107,9 +107,6 @@ class BuildcostAccessCache(BasicCache):
# time function to use for measuring build-times
_time = gettime
def __init__(self, maxentries=64):
super(BuildcostAccessCache, self).__init__(maxentries)
def build(self, key, builder, *args, **kwargs):
start = self._time()
val = builder(*args, **kwargs)

View File

@ -27,6 +27,12 @@ class TestBuildcostAccess(BasicCacheAPITest):
def test_cache_works_somewhat_simple(self):
cache = BuildcostAccessCache()
# the default ._time() call used by
# BuildcostAccessCache.build can
# result into time()-time() == 0 which makes the below
# test fail randomly. Let's rather use incrementing
# numbers instead.
cache._time = py.std.itertools.count().next
for x in range(cache.maxentries):
y = cache.getorbuild(x, lambda: x)
assert x == y