refactor as procedural
[arvados.git] / sdk / python / tests / test_arv_copy.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import io
5 import os
6 import sys
7 import tempfile
8 import unittest
9
10 import arvados.commands.arv_copy as arv_copy
11 import arvados_testutil as tutil
12
13 class ArvCopyTestCase(unittest.TestCase):
14     def run_copy(self, args):
15         sys.argv = ['arv-copy'] + args
16         return arv_copy.main()
17
18     def test_unsupported_arg(self):
19         with self.assertRaises(SystemExit):
20             self.run_copy(['-x=unknown'])
21
22     def test_version_argument(self):
23         err = io.BytesIO()
24         out = io.BytesIO()
25         with tutil.redirected_streams(stdout=out, stderr=err):
26             with self.assertRaises(SystemExit):
27                 self.run_copy(['--version'])
28         self.assertEqual(out.getvalue(), '')
29         self.assertRegexpMatches(err.getvalue(), "[0-9]+\.[0-9]+\.[0-9]+")