def test_cache_function_works_after_cleanup(): first = func() clear_cache(func) second = func() third = func() assert first != second assert second == third
def test_cached_method_kwargs(subject): clear_cache(subject) assert subject.cached_method_3(value=1) == 1 assert subject.cached_method_3(value=1) == 1 assert subject.cached_method_3(value=2) == 2 assert subject.cached_method_3(value=2) == 2 with ignoring_cache(): assert subject.cached_method_3(value=1) == 3 assert subject.cached_method_3(value=2) == 4 assert subject.cached_method_3(value=1) == 3 assert subject.cached_method_3(value=2) == 4
def test_cached_method_no_args_and_kwargs(subject): clear_cache(subject) assert subject.cached_method_4() == 1 assert subject.prop == 2 assert subject.cached_method_4() == 1 clear_cache(subject)
def test_cached_method_mutable_kwargs(subject): clear_cache(subject) assert subject.cached_method_3(value=[1]) == 1 assert subject.cached_method_3(value=[1]) == 2
def test_cached_method_clear_cache(subject): assert subject.cached_method_1(1) == 1 assert subject.cached_method_1(1) == 1 clear_cache(subject) assert subject.cached_method_1(1) == 2
def test_cache_function_clear_cache_works(): before = func() clear_cache(func) after = func() assert before != after
def test_subject_clear_cache(subject): assert subject.prop == 1 clear_cache(subject) assert subject.prop == 2
def test_cached_method_kwargs(subject): clear_cache(subject) assert subject.cached_method_3(value=1) == 1 assert subject.cached_method_3(value=1) == 1 assert subject.cached_method_3(value=2) == 2 assert subject.cached_method_3(value=2) == 2
def test_cached_method_args(subject): clear_cache(subject) assert subject.cached_method_3(1) == 1 assert subject.cached_method_3(1) == 1 assert subject.cached_method_3(2) == 2 assert subject.cached_method_3(2) == 2