Skip to content

Commit b8eacc4

Browse files
author
Vasileios Karakasis
committed
Replace use of datetime with time.time()
1 parent c511a53 commit b8eacc4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

unittests/test_schedulers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ def test_submit(make_job, exec_ctx):
283283
def test_submit_timelimit(minimal_job, local_only):
284284
minimal_job.time_limit = '2s'
285285
prepare_job(minimal_job, 'sleep 10')
286-
t_job = datetime.now()
286+
t_job = time.time()
287287
minimal_job.submit()
288288
assert minimal_job.jobid is not None
289289
minimal_job.wait()
290-
t_job = datetime.now() - t_job
291-
assert t_job.total_seconds() >= 2
292-
assert t_job.total_seconds() < 3
290+
t_job = time.time() - t_job
291+
assert t_job >= 2
292+
assert t_job < 3
293293
with open(minimal_job.stdout) as fp:
294294
assert re.search('postrun', fp.read()) is None
295295

@@ -319,7 +319,7 @@ def test_submit_job_array(make_job, slurm_only, exec_ctx):
319319
def test_cancel(make_job, exec_ctx):
320320
minimal_job = make_job(sched_access=exec_ctx.access)
321321
prepare_job(minimal_job, 'sleep 30')
322-
t_job = datetime.now()
322+
t_job = time.time()
323323
minimal_job.submit()
324324
minimal_job.cancel()
325325

@@ -331,9 +331,9 @@ def test_cancel(make_job, exec_ctx):
331331
time.sleep(0.01)
332332

333333
minimal_job.wait()
334-
t_job = datetime.now() - t_job
334+
t_job = time.time() - t_job
335335
assert minimal_job.finished()
336-
assert t_job.total_seconds() < 30
336+
assert t_job < 30
337337

338338
# Additional scheduler-specific checks
339339
sched_name = minimal_job.scheduler.registered_name

0 commit comments

Comments
 (0)