Skip to content

Commit 0e05015

Browse files
committed
Use a defined sourceTime when using parsedatetime
When using the parsedatetime functionalities freezegun is not used to compute the source time. If the tests are run too close to midnight it might result in the computation of 'tomorrow' being another day then now() + 24h (because time.localtime() will be the next day) … thus failing test_default_due2. Setting sourceTime when calling parsedatime will ensure the same base is used for all tests.
1 parent cf1df4a commit 0e05015

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

todoman/formatters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ def _parse_datetime_naive(self, dt):
192192
except ValueError:
193193
pass
194194

195-
rv, pd_ctx = self._parsedatetime_calendar.parse(dt)
195+
now = datetime.datetime.now(self.tz)
196+
rv, pd_ctx = self._parsedatetime_calendar.parse(dt, now)
196197
if not pd_ctx.hasDateOrTime:
197198
raise ValueError('Time description not recognized: {}'.format(dt))
198199
return datetime.datetime.fromtimestamp(mktime(rv))

0 commit comments

Comments
 (0)