Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make sure tests pass on redis 2.4. merges #271

  • Loading branch information...
commit fd82c5d6cdcc2596b6cf5a0e053658b4c78ee867 1 parent 2eafadd
andy authored
Showing with 18 additions and 8 deletions.
  1. +1 −0  CHANGES
  2. +4 −2 redis/client.py
  3. +13 −6 tests/server_commands.py
View
1  CHANGES
@@ -1,5 +1,6 @@
* 2.6.3 (in development)
* Added BITOP and BITCOUNT commands. Thanks Mark Tozzi.
+ * Added the TIME command. Thanks Jason Knight.
* 2.6.2
* `from_url` is now available as a classmethod on client classes. Thanks
Jon Parise for the patch.
View
6 redis/client.py
@@ -373,8 +373,10 @@ def dbsize(self):
return self.execute_command('DBSIZE')
def time(self):
- """Returns the server time in (seconds since epoch, microseconds
- into this second)."""
+ """
+ Returns the server time as a 2-item tuple of ints:
+ (seconds since epoch, microseconds into this second).
+ """
return self.execute_command('TIME')
def debug_object(self, key):
View
19 tests/server_commands.py
@@ -38,12 +38,6 @@ def test_dbsize(self):
self.client['b'] = 'bar'
self.assertEquals(self.client.dbsize(), 2)
- def test_time(self):
- first = self.client.time()
- time.sleep(0.05)
- second = self.client.time()
- self.assertLess(first, second)
-
def test_get_and_set(self):
# get and set can't be tested independently of each other
client = redis.Redis(host='localhost', port=6379, db=9)
@@ -122,6 +116,19 @@ def test_object(self):
def test_ping(self):
self.assertEquals(self.client.ping(), True)
+ def test_time(self):
+ version = self.client.info()['redis_version']
+ if StrictVersion(version) < StrictVersion('2.6.0'):
+ try:
+ raise unittest.SkipTest()
+ except AttributeError:
+ return
+
+ t = self.client.time()
+ self.assertEquals(len(t), 2)
+ self.assert_(isinstance(t[0], int))
+ self.assert_(isinstance(t[1], int))
+
# KEYS
def test_append(self):
# invalid key type
Please sign in to comment.
Something went wrong with that request. Please try again.