mock 'time()' in cache tests

instead of calling 'sleep()' to let time advance.

This shortens the time needed to run those tests,
and ensures consistent results.
(Tests would randomly fail when using 'sleep()')
This commit is contained in:
Mike Fährmann
2020-05-09 23:55:14 +02:00
parent 42f29c3e11
commit 8b60bd6a91
2 changed files with 36 additions and 18 deletions

View File

@@ -57,7 +57,7 @@ class MemoryCacheDecorator(CacheDecorator):
value, expires = self.cache[key]
except KeyError:
expires = 0
if expires < timestamp:
if expires <= timestamp:
value = self.func(*args, **kwargs)
expires = timestamp + self.maxage
self.cache[key] = value, expires