Kaynağa Gözat

Merge branch 'nvie/master'

Ask Solem 15 yıl önce
ebeveyn
işleme
ddc22ef5c2
2 değiştirilmiş dosya ile 10 ekleme ve 1 silme
  1. 4 1
      celery/task/schedules.py
  2. 6 0
      celery/tests/test_task.py

+ 4 - 1
celery/task/schedules.py

@@ -81,7 +81,10 @@ class crontab_parser(object):
         try:
             i = int(toks[0])
         except ValueError:
-            i = weekday(toks[0])
+            try:
+                i = weekday(toks[0])
+            except KeyError:
+                raise ValueError("Invalid weekday literal '%s'." % toks[0])
         return [i]
 
     @staticmethod

+ 6 - 0
celery/tests/test_task.py

@@ -618,6 +618,12 @@ class test_crontab_is_due(unittest.TestCase):
         c = crontab(day_of_week='*/2')
         self.assertEquals(c.day_of_week, set([0,2,4,6]))
 
+    def test_crontab_spec_invalid_dow(self):
+        self.assertRaises(ValueError, crontab, day_of_week='fooday-barday')
+        self.assertRaises(ValueError, crontab, day_of_week='1,4,foo')
+        self.assertRaises(ValueError, crontab, day_of_week='7')
+        self.assertRaises(ValueError, crontab, day_of_week='12')
+
     def test_every_minute_execution_is_due(self):
         last_ran = datetime.now() - timedelta(seconds=61)
         due, remaining = EveryMinutePeriodic().is_due(last_ran)