From fd8f3c2f659d468f34710445925a4e4f1385c5f5 Mon Sep 17 00:00:00 2001 From: Trey Long Date: Tue, 26 Jan 2016 19:07:24 -0500 Subject: [PATCH] added test to fail on memcached type --- test_cache.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test_cache.py b/test_cache.py index 9811572..d62cfc3 100644 --- a/test_cache.py +++ b/test_cache.py @@ -618,6 +618,23 @@ def test_20_jinja2ext_cache(self): k = make_template_fragment_key("fragment4", vary_on=["fragment5"]) assert self.cache.get(k) == somevar assert output == somevar + + def test_21_memoized_custom_repr(self): + with self.app.test_request_context(): + class SlowClass(object): + @self.cache.memoize() + def slow_func(self, a, b): + return a + b, random.randrange(0, 100000) + + def __repr__(self): + return "A SLOW CLASS" + + sc = SlowClass() + result_a, rand_a = sc.slow_func(1, 2) + assert(result_a == 3) + result_b, rand_b = sc.slow_func(1, 2) + assert(result_b == 3) + assert(rand_a == rand_b) if 'TRAVIS' in os.environ: