Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for floating point timedelta.

  • Loading branch information...
commit 5ec2eba0c4ce056f88b90047e2798455a781c8f9 1 parent 313a2f2
@mmerickel mmerickel authored
View
5 anykeystore/tests/test_backends/test_memory.py
@@ -1,3 +1,5 @@
+import time
+
import unittest2 as unittest
class TestMemoryStore(unittest.TestCase):
@@ -25,6 +27,7 @@ def test_it_old(self):
def test_it_purge(self):
store = self._makeOne()
- store.store('foo', 'bar', expires=-1)
+ store.store('foo', 'bar', expires=0.01)
+ time.sleep(0.02)
store.purge_expired()
self.assertRaises(KeyError, store.retrieve, 'foo')
View
5 anykeystore/tests/test_backends/test_mongodb.py
@@ -1,3 +1,5 @@
+import time
+
import unittest2 as unittest
def setUpModule():
@@ -32,6 +34,7 @@ def test_it_old(self):
def test_it_purge(self):
store = self._makeOne()
- store.store('foo', 'bar', expires=-1)
+ store.store('foo', 'bar', expires=0.01)
+ time.sleep(0.1)
store.purge_expired()
self.assertRaises(KeyError, store.retrieve, 'foo')
View
5 anykeystore/tests/test_backends/test_sqla.py
@@ -1,3 +1,5 @@
+import time
+
import unittest2 as unittest
class TestSQLStore(unittest.TestCase):
@@ -27,6 +29,7 @@ def test_it_old(self):
def test_it_purge(self):
store = self._makeOne()
- store.store('foo', 'bar', expires=-1)
+ store.store('foo', 'bar', expires=0.01)
+ time.sleep(0.05)
store.purge_expired()
self.assertRaises(KeyError, store.retrieve, 'foo')
View
2  anykeystore/utils.py
@@ -3,5 +3,5 @@
def coerce_timedelta(value):
if isinstance(value, timedelta):
return value
- if isinstance(value, int):
+ if isinstance(value, int) or isinstance(value, float):
return timedelta(seconds=value)
Please sign in to comment.
Something went wrong with that request. Please try again.