def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found( self): lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"]) lm.mpirun = "mpifoo" self.assertRaises( IOError, lm.check_files, MockExecutable(sys.executable), "main_file" ) # main_file does not exist either, but mpirun is checked first
class TestDistributedLaunchMode(unittest.TestCase, BaseTestLaunchMode): def setUp(self): self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"]) if self.lm.mpirun is None: raise unittest.SkipTest("mpiexec not found") def tearDown(self): for path in "valid_test_script.py", "invalid_test_script.py", "test_parameters": if os.path.exists(path): os.remove(path) def test__init__should_not_raise_an_exception_if_the_mpiexec_is_not_found(self): lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"]) def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(self): lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"]) lm.mpirun = "mpifoo" self.assertRaises(IOError, lm.check_files, MockExecutable(sys.executable), "main_file") # main_file does not exist either, but mpirun is checked first def test__init__should_set_mpirun_to_the_full_path(self): for path in "/usr/bin/mpiexec", "/usr/local/bin/mpiexec": if os.path.exists(path): self.assertEqual(self.lm.mpirun, path) break def test_getstate_should_return_an_appropriate_dict(self): self.assertEqual(self.lm.__getstate__(), {'working_directory': self.lm.working_directory, 'mpirun': self.lm.mpirun, 'n': 2, 'options': None, 'hosts': ["node1", "node2"], 'pfi_path': '/usr/local/bin/pfi.py'})
def __init__(self, np=1, reason=None, label=None): self.np = np self.reason = reason self.label = label + '_' + time.strftime("%d%m%y-%H%M%S") if self.np > 1: self.launchmode = DistributedLaunchMode(self.np) self.executable = sumatra.programs.Executable(path="mpirun") else: self.launchmode = SerialLaunchMode() self.executable = sumatra.programs.PythonExecutable( path=sys.executable)
def setUp(self): self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"]) if self.lm.mpirun is None: raise unittest.SkipTest("mpiexec not found")
def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(self): lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"]) lm.mpirun = "mpifoo" self.assertRaises(IOError, lm.check_files, MockExecutable(sys.executable), "main_file") # main_file does not exist either, but mpirun is checked first
def test__init__should_not_raise_an_exception_if_the_mpiexec_is_not_found(self): lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])