Ejemplo n.º 1
0
def test_cache_full(cache: Cache):
    """Test that cache.full() returns whether the cache is full or not."""
    for n in range(cache.maxsize):
        assert not cache.full()
        cache.set(n, n)

    assert cache.full()
Ejemplo n.º 2
0
def test_cache_full_maxsize_negative():
    """Test that cache.full() works when maxsize is negative."""
    cache = Cache()
    cache.maxsize = -1
    for n in range(1000):
        cache.set(n, n)
        assert not cache.full()
Ejemplo n.º 3
0
def test_cache_full_unbounded(cache: Cache):
    """Test that cache.full() always returns False for an unbounded cache."""
    cache.configure(maxsize=0)
    for n in range(1000):
        cache.set(n, n)
        assert not cache.full()
Ejemplo n.º 4
0
def test_cache_full_maxsize_none():
    """Test that cache.full() works when maxsize is None."""
    cache = Cache(maxsize=None)
    for n in range(1000):
        cache.set(n, n)
        assert not cache.full()
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
# __file__  : cache_study.py
# __time__  : 2020/6/29 5:55 下午

from cacheout import Cache

c = Cache()
# c.add()
c.full()


def MyRange(end):
    start = 0
    while start < end:
        x = yield start  # 这里增加了获取返回值
        print(x, "0")  # 打印出来
        start += 1


m = MyRange(5)
print(next(m))
print(next(m))


def MyRange(end):
    start = 0
    while start < end:
        x = yield start
        print(x)
        start += 1