diff --git a/rq/queue.py b/rq/queue.py index 621942a..7569104 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -68,6 +68,9 @@ class Queue(object): job_class = import_attribute(job_class) self.job_class = job_class + def __len__(self): + return self.count + @property def key(self): """Returns the Redis key for this Queue.""" diff --git a/tests/test_queue.py b/tests/test_queue.py index c60b510..e61568e 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -101,11 +101,13 @@ class TestQueue(RQTestCase): q.enqueue(say_hello, 'Charlie') self.testconn.lpush(q.key, '1', '2') - self.assertEquals(q.count, 4) + self.assertEqual(q.count, 4) + self.assertEqual(len(q), 4) q.compact() - self.assertEquals(q.count, 2) + self.assertEqual(q.count, 2) + self.assertEqual(len(q), 2) def test_enqueue(self): """Enqueueing job onto queues."""