Skip to content

Commit 35d6392

Browse files
wxtimMetRonnie
andauthored
Apply suggestions from code review
Co-authored-by: Ronnie Dutta <[email protected]>
1 parent 1bc013f commit 35d6392

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,6 @@ def patch(time_zone: str = 'XXX-19:17'):
218218
try:
219219
yield patch
220220
finally:
221-
time.tzset() # Reset to the original time zone after the test
221+
# Reset to the original time zone after the test
222+
monkeypatch.undo()
223+
time.tzset()

tests/integration/test_workflow_db_mgr.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,18 @@ async def test_time_zone_writing(
193193
194194
https://github.com/cylc/cylc-flow/issues/6701
195195
"""
196-
set_timezone('XXX')
197-
wid = flow(one_conf)
198-
schd = scheduler(wid, paused_start=False, run_mode='live')
196+
set_timezone('XXX-19:00')
197+
schd = scheduler(flow(one_conf), paused_start=False, run_mode='live')
199198
async with start(schd):
200199
itask = schd.pool.get_tasks()[0]
200+
now = datetime.now().astimezone()
201+
set_timezone('XXX-19:17')
201202
schd.submit_task_jobs([itask])
202-
set_timezone()
203-
schd.task_events_mgr.process_message(itask, 'INFO', 'submitted')
204-
205-
# Check the db time_submit (defective) against time_submit_exit
206-
# which was ok:
207-
(time_submit, time_submit_exit), = db_select(
208-
schd, False, 'task_jobs', 'time_submit', 'time_submit_exit'
209-
)
210-
time_submit = datetime.strptime(time_submit, '%Y-%m-%dT%H:%M:%S%z')
211-
time_submit_exit = datetime.strptime(
212-
time_submit_exit, '%Y-%m-%dT%H:%M:%S%z'
213-
)
214203

215-
assert time_submit_exit >= time_submit
216-
# The two times should be approx the same:
217-
assert time_submit_exit < time_submit + timedelta(seconds=10)
204+
# Check the db time_submit:
205+
(time_submit,) = db_select(schd, False, 'task_jobs', 'time_submit')[0]
206+
time_submit = datetime.strptime(time_submit, '%Y-%m-%dT%H:%M:%S%z')
207+
# The submit time should be approx correct:
208+
assert (
209+
abs(time_submit - now) < timedelta(seconds=10)
210+
), f"{time_submit} ~= {now}"

0 commit comments

Comments
 (0)