def test_executable(self): with nostderrout(): run_matlab(program='./input/matlab_test_script.m', executable='matlab') self.assert_proper_output('../output/make.log') self.assertTrue(os.path.isfile('../output/matlab_test.mat')) self.assertTrue(os.path.isfile('../output/matlab_test.eps'))
def test_default_log(self): with nostderrout(): run_matlab(program='./input/matlab_test_script.m') self.assert_proper_output('../output/make.log') logfile_data = open('../output/make.log', 'r').read() self.assertIn('Time : ', logfile_data) self.assertTrue(os.path.isfile('../output/matlab_test.mat')) self.assertTrue(os.path.isfile('../output/matlab_test.eps'))
def test_independent_log(self): with nostderrout(): run_matlab(program='./input/matlab_test_script.m', log='../output/matlab.log') self.assert_proper_output('../output/make.log') self.assertTrue(os.path.isfile('../output/matlab.log')) self.assert_proper_output('../output/matlab.log') self.assertTrue(os.path.isfile('../output/matlab_test.mat')) self.assertTrue(os.path.isfile('../output/matlab_test.eps'))
def test_custom_log(self): os.remove('../output/make.log') makelog_file = '../output/custom_make.log' output_dir = '../output/' with nostderrout(): clear_output_dirs(output_dir, '') start_make_logging(makelog_file) run_matlab(program='./input/matlab_test_script.m', makelog='../output/custom_make.log') self.assert_proper_output('../output/custom_make.log') self.assertTrue(os.path.isfile('../output/matlab_test.mat')) self.assertTrue(os.path.isfile('../output/matlab_test.eps'))
def test_option(self): with nostderrout(): run_matlab(program='./input/matlab_test_script.m', option='-h') logfile_data = open('../output/make.log', 'r').read() self.assertIn('-help', logfile_data)
def test_no_program(self): with nostderrout(): run_matlab(program='./input/nonexistent_matlab_script.m') logfile_data = open('../output/make.log', 'r').readlines() self.assertIn('CritError:', logfile_data[-1])
def test_bad_executable(self): with nostderrout(): run_matlab(program='./input/matlab_test_script.m', executable='nonexistent_matlab_executable') logfile_data = open('../output/make.log', 'r').read() self.assertIn('executed with errors', logfile_data)
def test_no_extension(self): with nostderrout(): run_matlab(program='./input/matlab_test_script') self.assert_proper_output('../output/make.log') self.assertTrue(os.path.isfile('../output/matlab_test.mat')) self.assertTrue(os.path.isfile('../output/matlab_test.eps'))