Skip to content

Commit 5bd3c86

Browse files
committed
Small changes in TestSlurmQueue
1 parent b2c17a3 commit 5bd3c86

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

smartdispatch/tests/test_job_generator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,15 @@ def setUp(self):
295295
self.dummy_pbs = dummy_generator.pbs_list
296296

297297
def test_ppn_ncpus(self):
298-
assert_true("ppn" not in str(self.pbs[0]))
299-
assert_true("ncpus" in str(self.pbs[0]))
300298
assert_true("ppn" in str(self.dummy_pbs[0]))
301299
assert_true("ncpus" not in str(self.dummy_pbs[0]))
300+
assert_true("ppn" not in str(self.pbs[0]))
301+
assert_true("ncpus" in str(self.pbs[0]))
302+
302303

303304
def test_gpus_naccelerators(self):
305+
assert_true("gpus" in str(self.dummy_pbs[0]))
306+
assert_true("naccelerators" not in str(self.dummy_pbs[0]))
304307
assert_true("gpus" not in str(self.pbs[0]))
305308
assert_true("naccelerators" in str(self.pbs[0]))
306309

smartdispatch/tests/test_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import unittest
33
try:
44
from mock import patch
5-
import mock
65
except ImportError:
76
from unittest.mock import patch
8-
import unittest.mock
7+
98
from nose.tools import assert_equal, assert_true
109
from numpy.testing import assert_array_equal
1110
import subprocess

smartdispatch/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ def detect_cluster():
133133
return cluster_name
134134

135135
def get_slurm_cluster_name():
136-
stdout = Popen("sacctmgr list cluster", stdout=PIPE, shell=True).communicate()[0]
136+
try:
137+
stdout = Popen("sacctmgr list cluster", stdout=PIPE, shell=True).communicate()[0]
138+
except OSError:
139+
return None
137140
stdout = stdout.decode()
138141
cluster_name = stdout.splitlines()[2].strip().split(' ')[0]
139142
return cluster_name

0 commit comments

Comments
 (0)