Exemplo n.º 1
0
def test_pattern_cache():
    convoluted_pat_text = ",".join([str(x) for x in range(0, 1000, 2)])
    _compile_pattern.cache_clear()
    assert _compile_pattern.cache_info().currsize == 0
    assert pattern_matches(convoluted_pat_text, "32")
    assert _compile_pattern.cache_info().currsize == 1
    assert _compile_pattern.cache_info().misses == 1
    assert not pattern_matches(convoluted_pat_text, "31")
    assert _compile_pattern.cache_info().currsize == 1
    assert _compile_pattern.cache_info().misses == 1
    assert _compile_pattern.cache_info().hits == 1
Exemplo n.º 2
0
def test_pattern_cache():
    convoluted_pat_text = ",".join([str(x) for x in range(0, 1000, 2)])
    _compile_pattern.cache_clear()
    assert _compile_pattern.cache_info().currsize == 0
    assert pattern_matches(convoluted_pat_text, "32")
    assert _compile_pattern.cache_info().currsize == 1
    assert _compile_pattern.cache_info().misses == 1
    assert not pattern_matches(convoluted_pat_text, "31")
    assert _compile_pattern.cache_info().currsize == 1
    assert _compile_pattern.cache_info().misses == 1
    assert _compile_pattern.cache_info().hits == 1