[py-svn] r58576 - in py/trunk/py/misc: . testing
hpk at codespeak.net
hpk at codespeak.net
Thu Oct 2 18:19:06 CEST 2008
Author: hpk
Date: Thu Oct 2 18:19:04 2008
New Revision: 58576
Modified:
py/trunk/py/misc/cache.py
py/trunk/py/misc/testing/test_cache.py
Log:
* fix test to not rely on time.time() resolution
* strike some superflous __init__ code
Modified: py/trunk/py/misc/cache.py
==============================================================================
--- py/trunk/py/misc/cache.py (original)
+++ py/trunk/py/misc/cache.py Thu Oct 2 18:19:04 2008
@@ -107,9 +107,6 @@
# 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)
Modified: py/trunk/py/misc/testing/test_cache.py
==============================================================================
--- py/trunk/py/misc/testing/test_cache.py (original)
+++ py/trunk/py/misc/testing/test_cache.py Thu Oct 2 18:19:04 2008
@@ -27,6 +27,12 @@
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
More information about the pytest-commit
mailing list