def test_program_space(self): with no_stderrout(): paths = self.make_paths(makelog_path = 'test/log/make space.log') program_name = 'test/raw/run_program/%s_script space.%s' % (self.app, self.ext) run_function(paths, program = program_name) self.check_output(paths)
def test_program(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext) run_function(paths, program = program_name) self.check_output(paths)
def test_log_space(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext) run_function(paths, program = program_name, log = 'test/output/log space.log') self.check_output(paths) self.assertIn('Test script complete', read_file('test/output/log space.log'))
def test_error_bad_arg(self): try: with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext) run_function(paths, program = program_name, arg = []) except Exception as e: self.assertRaises(Exception, e)
def test_program_handout(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_file_handout.%s' % ( self.app, self.ext) run_function(paths, program=program_name, doctype='handout') self.check_output(paths, '%s_file_handout.pdf' % self.app)
def test_error_program_wrong_extension(self): try: with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/wrong_extension.txt' run_function(paths, program = program_name) except Exception as e: self.assertRaises(Exception, e)
def test_program_character(self): with no_stderrout(): paths = self.make_paths(makelog_path='test/log/make_╬▓.log') program_name = 'test/raw/run_program/%s_file_╬▓.%s' % (self.app, self.ext) run_function(paths, program=program_name) self.check_output(paths, '%s_file_╬▓.pdf' % self.app)
def test_no_log(self): with no_stderrout(): paths = self.make_paths(makelog_path = '') program_name = 'test/raw/run_program/%s_script.%s' % (self.app, self.ext) run_function(paths, program = program_name, log = '') self.assertFalse(os.path.isfile(paths['makelog'])) self.assertFalse(os.path.isfile('test/output/log.log')) self.assertTrue(os.path.isfile('test/output/output.csv'))
def test_program_arg(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_script_arg.%s' % (self.app, self.ext) run_function(paths, program = program_name, args = self.arg) self.check_output(paths) output = read_file('test/output/output.csv') self.assertTrue(re.search('arg', output))
def test_error_program_missing(self): try: with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_file_missing.%s' % ( self.app, self.ext) run_function(paths, program=program_name) except Exception as e: self.assertRaises(Exception, e)
def test_program_executable(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_file.%s' % (self.app, self.ext) run_function(paths, program=program_name, executable=self.executable) self.check_output(paths)
def test_log_character(self): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_file.%s' % (self.app, self.ext) run_function(paths, program=program_name, log='test/output/log_╬▓.log') self.check_output(paths) self.assertIn('Executing command', read_file('test/output/log_╬▓.log'))
def test_program_character(self): """ Note ---- Rscript can have difficulties finding file names with non-ASCII characters. """ with no_stderrout(): paths = self.make_paths(makelog_path = 'test/log/make_╬▓.log') program_name = 'test/raw/run_program/%s_script_╬▓.%s' % (self.app, self.ext) run_function(paths, program = program_name) self.check_output(paths)
def test_error_bad_program(self): with self.assertRaises(Exception): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/%s_script_error.%s' % (self.app, self.ext) run_function(paths, program = program_name)
def test_error_program_dir(self): with self.assertRaises(Exception): with no_stderrout(): paths = self.make_paths() program_name = 'test/raw/run_program/program/' run_function(paths, program = program_name)