Browse Source

Fixes failing test

Ask Solem 9 years ago
parent
commit
c673fe201b
2 changed files with 9 additions and 2 deletions
  1. 6 0
      celery/beat.py
  2. 3 2
      celery/tests/app/test_beat.py

+ 6 - 0
celery/beat.py

@@ -145,6 +145,12 @@ class ScheduleEntry(object):
 
     def __lt__(self, other):
         if isinstance(other, ScheduleEntry):
+            # How the object is ordered doesn't really matter, as
+            # in the scheduler heap, the order is decided by the
+            # preceding members of the tuple ``(time, priority, entry)``.
+            #
+            # If all that is left to order on is the entry then it can
+            # just as well be random.
             return id(self) < id(other)
         return NotImplemented
 

+ 3 - 2
celery/tests/app/test_beat.py

@@ -92,8 +92,9 @@ class test_ScheduleEntry(AppCase):
     def test_lt(self):
         e1 = self.create_entry(schedule=timedelta(seconds=10))
         e2 = self.create_entry(schedule=timedelta(seconds=2))
-        self.assertLess(e2, e1)
-        self.assertTrue(e1 < object())
+        # order doesn't matter, see comment in __lt__
+        res1 = e1 < e2  # noqa
+        res2 = e1 < object()  # noqa
 
     def test_update(self):
         entry = self.create_entry()