def test_max_ttl(): cem = Cemetery(max_ttl_secs=0.05) cem.add(1, 0.2) assert 1 in cem yield gen.sleep(0.05) assert 1 not in cem
def test_add_and_explicit_forget(): cem = Cemetery(ttl_offset_secs=0.01) cem.add(1, 0.05) yield gen.sleep(0.04) assert 1 in cem cem.forget(1) assert 1 not in cem
def test_add_and_forget(): cem = Cemetery(ttl_offset_secs=0.01) cem.add(1, 0.01) cem.add(2, 0.05) assert 1 in cem assert 2 in cem yield gen.sleep(0.020) assert 1 not in cem assert 2 in cem
def test_clear(): cem = Cemetery() cem.add(1, 0.1) cem.add(2, 0.2) assert 1 in cem assert 2 in cem cem.clear() assert 1 not in cem assert 2 not in cem