Skip to content
Browse files

Merge branch 'dhepper/master'

  • Loading branch information...
2 parents bf52e88 + f4f8e3b commit e3bac52ba50e96f57a54c5a2f604b0b544b2e3f6 @ask committed
Showing with 9 additions and 10 deletions.
  1. +2 −5 celery/schedules.py
  2. +7 −5 celery/tests/test_task/__init__.py
View
7 celery/schedules.py
@@ -153,15 +153,12 @@ def _expand_range(self, toks):
def _range_steps(self, toks):
if len(toks) != 3 or not toks[2]:
raise self.ParseException("empty filter")
- return self._filter_steps(self._expand_range(toks[:2]), int(toks[2]))
+ return self._expand_range(toks[:2])[::int(toks[2])]
def _star_steps(self, toks):
if not toks or not toks[0]:
raise self.ParseException("empty filter")
- return self._filter_steps(self._expand_star(), int(toks[0]))
-
- def _filter_steps(self, numbers, steps):
- return [n for n in numbers if n % steps == 0]
+ return self._expand_star()[::int(toks[0])]
def _expand_star(self, *args):
return range(self.max_)
View
12 celery/tests/test_task/__init__.py
@@ -605,12 +605,14 @@ def test_parse_steps(self):
def test_parse_composite(self):
self.assertEqual(crontab_parser(8).parse('*/2'), set([0, 2, 4, 6]))
- self.assertEqual(crontab_parser().parse('2-9/5'), set([5]))
- self.assertEqual(crontab_parser().parse('2-10/5'), set([5, 10]))
- self.assertEqual(crontab_parser().parse('2-11/5,3'), set([3, 5, 10]))
+ self.assertEqual(crontab_parser().parse('2-9/5'), set([2, 7]))
+ self.assertEqual(crontab_parser().parse('2-10/5'), set([2, 7]))
+ self.assertEqual(crontab_parser().parse('2-11/5,3'), set([2, 3, 7]))
self.assertEqual(crontab_parser().parse('2-4/3,*/5,0-21/4'),
- set([0, 3, 4, 5, 8, 10, 12, 15, 16,
- 20, 25, 30, 35, 40, 45, 50, 55]))
+ set([0, 2, 4, 5, 8, 10, 12, 15, 16,
+ 20, 25, 30, 35, 40, 45, 50, 55]))
+ self.assertEqual(crontab_parser().parse('1-9/2'),
+ set([1, 3, 5, 7, 9]))
def test_parse_errors_on_empty_string(self):
with self.assertRaises(ParseException):

0 comments on commit e3bac52

Please sign in to comment.
Something went wrong with that request. Please try again.