Fixes for Python 2.6 and Python 3
authorGeorge Sakkis <george.sakkis@gmail.com>
Tue, 21 Apr 2015 10:09:05 +0000 (13:09 +0300)
committerGeorge Sakkis <george.sakkis@gmail.com>
Tue, 21 Apr 2015 10:09:05 +0000 (13:09 +0300)
cached_property.py
tests/test_cached_property.py

index ee896aec39fe8425fb055d3e9614b0b9e4a67985..4b77bbf52e4e020a0cdc387494cce3c814c1cd8b 100644 (file)
@@ -85,7 +85,7 @@ class cached_property_with_ttl(object):
         except KeyError:
             pass
         else:
-            ttl_expired = 0 < self.ttl < now - last_updated
+            ttl_expired = self.ttl and self.ttl < now - last_updated
             if not ttl_expired:
                 return value
 
index 1bca7ab215604b2c063ac0883ba79719f65780a2..1e0e68a577461e66d4d4cd6904f7b989eac700a9 100644 (file)
@@ -87,7 +87,8 @@ class TestCachedProperty(unittest.TestCase):
 
         # Typically descriptors return themselves if accessed though the class
         # rather than through an instance.
-        self.assertIsInstance(Check.add_cached, self.cached_property_factory)
+        self.assertTrue(isinstance(Check.add_cached,
+                                   self.cached_property_factory))
 
     def test_reset_cached_property(self):
         Check = CheckFactory(self.cached_property_factory)