Skip to content

Commit 2c73da0

Browse files
committed
fix doctest failure with today_patch
1 parent 4f42c1e commit 2c73da0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

things/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
def add_imports(doctest_namespace): # noqa
1010
"""Import default modules."""
1111
doctest_namespace["things"] = things
12+
13+
@pytest.fixture
14+
def patch_today(mocker):
15+
mock = mocker.patch("things.database.date_today")
16+
mock.return_value = '2025-09-01'

things/database.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,9 @@ def make_thingsdate_filter(date_column: str, value) -> str:
947947
>>> make_thingsdate_filter('startDate', False)
948948
'AND startDate IS NULL'
949949
950+
>>> today = getfixture('patch_today')
950951
>>> make_thingsdate_filter('startDate', 'future')
951-
"AND startDate > ((strftime('%Y', date('now', 'localtime')) << 16) \
952-
| (strftime('%m', date('now', 'localtime')) << 12) \
953-
| (strftime('%d', date('now', 'localtime')) << 7))"
952+
'AND startDate > 132747392'
954953
955954
>>> make_thingsdate_filter('deadline', '2021-03-28')
956955
'AND deadline == 132464128'

0 commit comments

Comments
 (0)