2 # -*- coding: utf-8 -*-
10 import arvados.commands.run as arv_run
12 class ArvRunTestCase(unittest.TestCase):
13 def run_arv_run(self, args):
14 sys.argv = ['arv-run'] + args
17 def run_arv_run_process(self, args):
18 _, stdout_path = tempfile.mkstemp()
19 _, stderr_path = tempfile.mkstemp()
22 sys.argv = ['arv-run'] + args
23 sys.stdout = open(stdout_path, 'w')
24 sys.stderr = open(stderr_path, 'w')
27 p = multiprocessing.Process(target=wrap())
30 out = open(stdout_path, 'r').read()
31 err = open(stderr_path, 'r').read()
32 os.unlink(stdout_path)
33 os.unlink(stderr_path)
34 return p.exitcode, out, err
36 def test_unsupported_arg(self):
37 with self.assertRaises(SystemExit):
38 self.run_arv_run(['-x=unknown'])
40 def test_version_argument(self):
41 exitcode, out, err = self.run_arv_run_process(['--version'])
42 self.assertEqual(0, exitcode)
43 self.assertEqual('', out)
44 self.assertNotEqual('', err)
45 self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")