Commit a6babab0 authored by payno's avatar payno

pep8

parent 2a613153
......@@ -61,12 +61,12 @@ class test_oarjob(unittest.TestCase):
self.assertTrue(oarjob.JobFactory())
self.assertTrue(oarjob.JobFactory(command='ls -all'))
res = Resource(nodes=1,cpu=2,core=2,gpu=True,mem_core_mb=8000)
res = Resource(nodes=1, cpu=2, core=2, gpu=True, mem_core_mb=8000)
info = oarjob.JobFactory(resource=res, command='ls -all', log_base='test')
cli = "-O test.stdout -E test.stderr -l nodes=1/cpu=2/core=2 -p \"gpu='YES' and mem_core_mb>=8000\" \"ls -all\""
self.assertEqual(cli,info.cli_string)
self.assertEqual(cli, info.cli_string)
def definition(self,seconds,name):
def definition(self, seconds, name):
command = 'python -c "from time import sleep\nfor i in range({}):\n print(i)\n sleep(1)"'
resource = Resource(core=1,walltime={'seconds':seconds*3})
jobdef = oarjob.JobFactory(name=name, project='oarpy',
......@@ -75,32 +75,32 @@ class test_oarjob(unittest.TestCase):
output = list(range(seconds))
return jobdef,output
def _check_output(self,job,expected):
def _check_output(self, job, expected):
output = [int(i) for i in job.stdout.split('\n') if i]
self.assertEqual(output,expected)
self.assertEqual(output, expected)
def test_immediate(self):
self.skipoar()
jobdef,expected = self.definition(5,'immediate')
jobdef, expected = self.definition(5, 'immediate')
job = jobdef.submit()
self.assertEqual(job.definition,jobdef)
self.assertEqual(job.definition, jobdef)
job.wait(silent=True)
self.assertEqual(job.exit_code,0)
self._check_output(job,expected)
self.assertEqual(job.exit_code, 0)
self._check_output(job, expected)
def test_notimmediate(self):
self.skipoar()
jobdef,expected = self.definition(5,'notimmediate')
jobdef, expected = self.definition(5, 'notimmediate')
job = jobdef.submit(hold=True)
job.wait(states=('Hold', 'Suspended'), silent=True)
job.resume()
job.wait(silent=True)
self.assertEqual(job.exit_code,0)
self._check_output(job,expected)
self.assertEqual(job.exit_code, 0)
self._check_output(job, expected)
def test_interrupt(self):
self.skipoar()
jobdef,expected = self.definition(60,'interrupt')
jobdef,expected = self.definition(60, 'interrupt')
job = jobdef.submit()
job.wait(states=('Running', 'Terminated', 'Error'), silent=True)
sleep(5)
......@@ -110,7 +110,7 @@ class test_oarjob(unittest.TestCase):
def test_suspend(self):
self.skipoar()
jobdef,expected = self.definition(60,'interrupt')
jobdef, expected = self.definition(60, 'interrupt')
job = jobdef.submit()
job.wait(states=('Running', 'Terminated', 'Error'), silent=True)
self.assertRaises(RuntimeError, job.suspend)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment