Commits

Mikhail Korobov committed 3677d8b

Failing test demonstrating invalidation bug

Comments (0)

Files changed (1)

cache_utils/tests.py

         cache.set('vasia', 'foo', 60, group='names')
         self.assertEqual(cache.get('vasia', group='names'), 'foo')
 
-    def test_decorator_invalidation(self):
+    def test_func_invalidation(self):
         self.call_count = 0
 
         @cached(60)
         self.assertEqual(my_func(3,2), 3)
         self.assertEqual(my_func(3,2), 3)
 
+    def test_method_invalidation(self):
+        self.call_count = 0
+        this = self
+
+        class Foo(object):
+            @cached(60)
+            def bar(self, x):
+                this.call_count += 1
+                return this.call_count
+
+        foo = Foo()
+        self.assertEqual(foo.bar(1), 1)
+        self.assertEqual(foo.bar(1), 1)
+        Foo.bar.invalidate(1)
+        self.assertEqual(foo.bar(1), 2)
+
 
 class DecoratorTest(ClearMemcachedTest):