def test_cache_last_used_update(diff_cache, use_file_io): p = '/path/last-used' parser_cache.clear() # Clear, because then it's easier to find stuff. parse('somecode', cache=True, path=p) node_cache_item = next(iter(parser_cache.values()))[p] now = time.time() assert node_cache_item.last_used < now if use_file_io: f = _FixedTimeFileIO(p, 'code', node_cache_item.last_used - 10) parse(file_io=f, cache=True, diff_cache=diff_cache) else: parse('somecode2', cache=True, path=p, diff_cache=diff_cache) node_cache_item = next(iter(parser_cache.values()))[p] assert now < node_cache_item.last_used < time.time()
def cache_size(): return sum(len(v) for v in parser_cache.values())