Skip to content

Commit

Permalink
Allow multiple spaces in crontab format (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-tielen authored and agronholm committed Dec 13, 2017
1 parent 7cad405 commit 89513a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apscheduler/triggers/cron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def from_crontab(cls, expr, timezone=None):
:return: a :class:`~CronTrigger` instance
"""
values = expr.split(' ')
values = expr.split()
if len(values) != 5:
raise ValueError('Wrong number of fields; got {}, expected 5'.format(len(values)))

Expand Down
5 changes: 4 additions & 1 deletion tests/test_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,12 @@ def test_invalid_ranges(self, values, expected):
"<CronTrigger (month='*', day='*', day_of_week='*', hour='*', minute='*', "
"timezone='Europe/Berlin')>"),
('0-14 * 14-28 jul fri',
"<CronTrigger (month='jul', day='14-28', day_of_week='fri', hour='*', minute='0-14', "
"timezone='Europe/Berlin')>"),
(' 0-14 * 14-28 jul fri',
"<CronTrigger (month='jul', day='14-28', day_of_week='fri', hour='*', minute='0-14', "
"timezone='Europe/Berlin')>")
], ids=['always', 'assorted'])
], ids=['always', 'assorted', 'multiple_spaces_in_format'])
def test_from_crontab(self, expr, expected_repr, timezone):
trigger = CronTrigger.from_crontab(expr, timezone)
assert repr(trigger) == expected_repr
Expand Down

0 comments on commit 89513a7

Please sign in to comment.