9 import arvnodeman.launcher as nodeman
11 class ArvNodemArgumentsTestCase(unittest.TestCase):
12 def run_nodeman(self, args):
13 return nodeman.main(args)
15 def run_nodeman_process(self, args=[]):
16 _, stdout_path = tempfile.mkstemp()
17 _, stderr_path = tempfile.mkstemp()
19 def wrapper(*args, **kwargs):
20 sys.stdout = open(stdout_path, 'w')
21 sys.stderr = open(stderr_path, 'w')
22 nodeman.main(*args, **kwargs)
24 p = multiprocessing.Process(target=wrap(), args=(args,))
27 out = open(stdout_path, 'r').read()
28 err = open(stderr_path, 'r').read()
29 os.unlink(stdout_path)
30 os.unlink(stderr_path)
31 return p.exitcode, out, err
33 def test_unsupported_arg(self):
34 with self.assertRaises(SystemExit):
35 self.run_nodeman(['-x=unknown'])
37 def test_version_argument(self):
38 exitcode, out, err = self.run_nodeman_process(['--version'])
39 self.assertEqual(0, exitcode)
40 self.assertEqual('', out)
41 self.assertNotEqual('', err)
42 self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")