def _cache(f): size, obsize = get_cache() # Smaller than obsize x = [f(i) for i in range(size)] # from the cache y = [f(i) for i in range(size)] # new instances del(x) # refil the cache z = [f(i) for i in range(size)] # from the cache again
def test_get_set_cache(self): assert get_cache() == (100, 128) set_cache(101, 128) assert get_cache() == (101, 128) with pytest.raises(ValueError): set_cache(-1, 128) with pytest.raises(ValueError): set_cache(100, -1) with pytest.raises(ValueError): set_cache(10001, 128) with pytest.raises(ValueError): set_cache(10001, 16385) with pytest.raises(TypeError): set_cache(mpz(100), 128) with pytest.raises(TypeError): set_cache(100, mpz(128)) # reset the cache paramaters for other tests set_cache(100, 128)