diff --git a/boltons/timeutils.py b/boltons/timeutils.py index 586f967..37a3a55 100644 --- a/boltons/timeutils.py +++ b/boltons/timeutils.py @@ -348,7 +348,7 @@ def daterange(start, stop, step=1, inclusive=False): ' (year, month, day), not: %r' % step) if stop is None: - finished = lambda t: False + finished = lambda now, stop: False elif start < stop: finished = operator.gt if inclusive else operator.ge else: diff --git a/tests/test_timeutils.py b/tests/test_timeutils.py index ba4d030..3e91ce6 100644 --- a/tests/test_timeutils.py +++ b/tests/test_timeutils.py @@ -47,3 +47,9 @@ def test_daterange_years(): assert years_from_2025[0] == date(2025, 1, 1) assert years_from_2025[-1] == date(2017, 1, 1) + +def test_daterange_infinite(): + today = date.today() + infinite_dates = daterange(today, None) + for i in range(10): + assert next(infinite_dates) == today + timedelta(days=i)