Added __len__ method to Queue.

main
Selwin Ong 10 years ago
parent fae7df5aa7
commit c1dc30eae3

@ -68,6 +68,9 @@ class Queue(object):
job_class = import_attribute(job_class) job_class = import_attribute(job_class)
self.job_class = job_class self.job_class = job_class
def __len__(self):
return self.count
@property @property
def key(self): def key(self):
"""Returns the Redis key for this Queue.""" """Returns the Redis key for this Queue."""

@ -101,11 +101,13 @@ class TestQueue(RQTestCase):
q.enqueue(say_hello, 'Charlie') q.enqueue(say_hello, 'Charlie')
self.testconn.lpush(q.key, '1', '2') self.testconn.lpush(q.key, '1', '2')
self.assertEquals(q.count, 4) self.assertEqual(q.count, 4)
self.assertEqual(len(q), 4)
q.compact() q.compact()
self.assertEquals(q.count, 2) self.assertEqual(q.count, 2)
self.assertEqual(len(q), 2)
def test_enqueue(self): def test_enqueue(self):
"""Enqueueing job onto queues.""" """Enqueueing job onto queues."""

Loading…
Cancel
Save