From cfa04cdd2a392b7b23a66c73f7326629d369c5f4 Mon Sep 17 00:00:00 2001 From: George Sakkis Date: Tue, 21 Apr 2015 13:09:05 +0300 Subject: [PATCH] Fixes for Python 2.6 and Python 3 --- cached_property.py | 2 +- tests/test_cached_property.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cached_property.py b/cached_property.py index ee896ae..4b77bbf 100644 --- a/cached_property.py +++ b/cached_property.py @@ -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 diff --git a/tests/test_cached_property.py b/tests/test_cached_property.py index 1bca7ab..1e0e68a 100644 --- a/tests/test_cached_property.py +++ b/tests/test_cached_property.py @@ -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) -- 2.30.2