@@ -197,6 +197,20 @@ def test_guess_num_tasks(self):
197197 with pytest .raises (NotImplementedError ):
198198 self .testjob .guess_num_tasks ()
199199
200+ # Monkey patch `self._update_state` to simulate that the job is
201+ # pending on the queue for enough time so it can be canceled due
202+ # to exceeding the maximum pending time
203+ @fixtures .switch_to_user_runtime
204+ def test_submit_max_pending_time (self ):
205+ self .setup_user ()
206+ self .parallel_cmd = 'sleep 30'
207+ self .prepare ()
208+ self .testjob .scheduler ._update_state = self ._update_state
209+ self .testjob ._max_pending_time = timedelta (seconds = 5 )
210+ self .testjob .submit ()
211+ with pytest .raises (JobError ):
212+ self .testjob .wait ()
213+
200214
201215class TestLocalJob (_TestJob , unittest .TestCase ):
202216 def assertProcessDied (self , pid ):
@@ -321,6 +335,10 @@ def test_guess_num_tasks(self):
321335 self .testjob .wait ()
322336 assert self .testjob .num_tasks == 1
323337
338+ def test_submit_max_pending_time (self ):
339+ pytest .skip ('the maximum pending time has no effect on the '
340+ 'local scheduler' )
341+
324342
325343class TestSlurmJob (_TestJob , unittest .TestCase ):
326344 @property
@@ -439,20 +457,6 @@ def test_submit_job_array(self):
439457 assert all ([re .search ('Task id: 0' , output ),
440458 re .search ('Task id: 1' , output )])
441459
442- # Monkey patch `self._update_state` to simulate that the job is
443- # pending on the queue for enough time so it can be canceled due
444- # to exceeding the maximum pending time
445- @fixtures .switch_to_user_runtime
446- def test_submit_max_pending_time (self ):
447- self .setup_user ()
448- self .parallel_cmd = 'sleep 30'
449- self .prepare ()
450- self .testjob .scheduler ._update_state = self ._update_state
451- self .testjob ._max_pending_time = timedelta (seconds = 5 )
452- self .testjob .submit ()
453- with pytest .raises (JobError ):
454- self .testjob .wait ()
455-
456460
457461class TestSqueueJob (TestSlurmJob ):
458462 @property
@@ -546,9 +550,12 @@ def test_prepare_no_cpus(self):
546550 assert self .expected_directives == found_directives
547551
548552 def test_submit_timelimit (self ):
549- # Skip this test for PBS, since we the minimum time limit is 1min
553+ # Skip this test for PBS, since the minimum time limit is 1min
550554 pytest .skip ("PBS minimum time limit is 60s" )
551555
556+ def test_submit_max_pending_time (self ):
557+ pytest .skip ('not implemented for the pbs scheduler' )
558+
552559
553560class TestTorqueJob (TestPbsJob ):
554561 @property
@@ -581,20 +588,6 @@ def test_submit_timelimit(self):
581588 def _update_state (self , job ):
582589 job .state = 'QUEUED'
583590
584- # Monkey patch `self._update_state` to simulate that the job is
585- # pending on the queue for enough time so it can be canceled due
586- # to exceeding the maximum pending time
587- @fixtures .switch_to_user_runtime
588- def test_submit_max_pending_time (self ):
589- self .setup_user ()
590- self .parallel_cmd = 'sleep 30'
591- self .prepare ()
592- self .testjob .scheduler ._update_state = self ._update_state
593- self .testjob ._max_pending_time = timedelta (seconds = 5 )
594- self .testjob .submit ()
595- with pytest .raises (JobError ):
596- self .testjob .wait ()
597-
598591
599592class TestSlurmFlexibleNodeAllocation (unittest .TestCase ):
600593 def create_dummy_nodes (obj ):
0 commit comments