9 import arvados.errors as arv_error
10 import arvados.commands.ws as arv_ws
12 class ArvWsTestCase(unittest.TestCase):
13 def run_ws(self, args):
14 return arv_ws.main(args)
16 def run_ws_process(self, args=[], api_client=None):
17 _, stdout_path = tempfile.mkstemp()
18 _, stderr_path = tempfile.mkstemp()
20 def wrapper(*args, **kwargs):
21 sys.stdout = open(stdout_path, 'w')
22 sys.stderr = open(stderr_path, 'w')
23 arv_ws.main(*args, **kwargs)
25 p = multiprocessing.Process(target=wrap(), args=(args,))
28 out = open(stdout_path, 'r').read()
29 err = open(stderr_path, 'r').read()
30 os.unlink(stdout_path)
31 os.unlink(stderr_path)
32 return p.exitcode, out, err
34 def test_unsupported_arg(self):
35 with self.assertRaises(SystemExit):
36 self.run_ws(['-x=unknown'])
38 def test_version_argument(self):
39 exitcode, out, err = self.run_ws_process(['--version'])
40 self.assertEqual(0, exitcode)
41 self.assertEqual('', out)
42 self.assertNotEqual('', err)
43 self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")