@@ -173,7 +173,10 @@ def format_test(start_out, end_out):
173
173
((datetime .date (2008 , 1 , 1 )),
174
174
format_test ('2008-01-01T00:00:00' , '2008-01-01T23:59:59.999999' )),
175
175
((datetime .date (2008 , 1 , 1 ), None ),
176
- format_test ('2008-01-01T00:00:00' , datetime .datetime .now ().strftime ("%Y-%m-%dT23:59:59.999999" ))),
176
+ # Starting the tests before midnight and finishing after will cause test failure
177
+ # since datetime.now() is evaluated before midnight and the test runs after midnight.
178
+ # Put the result behind a function that is evaluated inside the test instead.
179
+ lambda _ : format_test ('2008-01-01T00:00:00' , datetime .datetime .now ().strftime ("%Y-%m-%dT23:59:59.999999" ))),
177
180
((None , '2008' ),
178
181
format_test (datetime .datetime .fromtimestamp (0 ).strftime ("%Y-%m-%dT%H:%M:%S" ), '2008-12-31T23:59:59.999999' )),
179
182
]
@@ -183,7 +186,7 @@ def format_test(start_out, end_out):
183
186
def test_time_handling (time_param , expected ):
184
187
query = Query (time = time_param )
185
188
assert 'time' in query .search_terms
186
- assert query .search_terms ['time' ] == expected
189
+ assert query .search_terms ['time' ] == ( expected if isinstance ( expected , Range ) else expected ( "now" ))
187
190
188
191
189
192
def test_time_handling_int ():
0 commit comments