diff options
| -rwxr-xr-x | main.py | 3 | ||||
| -rw-r--r-- | tests/test_climat2.py | 12 |
2 files changed, 13 insertions, 2 deletions
| @@ -10,6 +10,7 @@ import multiprocessing | |||
| 10 | 10 | ||
| 11 | from src import parser_factory | 11 | from src import parser_factory |
| 12 | 12 | ||
| 13 | __version__ = '0.1' | ||
| 13 | 14 | ||
| 14 | def __check_file(filename:str, mode:int = os.R_OK) -> bool: | 15 | def __check_file(filename:str, mode:int = os.R_OK) -> bool: |
| 15 | if not os.path.isfile(filename): | 16 | if not os.path.isfile(filename): |
| @@ -24,6 +25,8 @@ def __check_file(filename:str, mode:int = os.R_OK) -> bool: | |||
| 24 | def create_arg_parser(): | 25 | def create_arg_parser(): |
| 25 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') | 26 | parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2') |
| 26 | parser.add_argument('files', nargs='*') | 27 | parser.add_argument('files', nargs='*') |
| 28 | parser.add_argument('-v', '--version', action='version', | ||
| 29 | version='MAT2 %s' % __version__) | ||
| 27 | 30 | ||
| 28 | info = parser.add_argument_group('Information') | 31 | info = parser.add_argument_group('Information') |
| 29 | info.add_argument('-c', '--check', action='store_true', | 32 | info.add_argument('-c', '--check', action='store_true', |
diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 44703b7..67b56eb 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py | |||
| @@ -8,12 +8,20 @@ class TestHelp(unittest.TestCase): | |||
| 8 | def test_help(self): | 8 | def test_help(self): |
| 9 | proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) | 9 | proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) |
| 10 | stdout, _ = proc.communicate() | 10 | stdout, _ = proc.communicate() |
| 11 | self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout) | 11 | self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout) |
| 12 | 12 | ||
| 13 | def test_no_arg(self): | 13 | def test_no_arg(self): |
| 14 | proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) | 14 | proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) |
| 15 | stdout, _ = proc.communicate() | 15 | stdout, _ = proc.communicate() |
| 16 | self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout) | 16 | self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout) |
| 17 | |||
| 18 | |||
| 19 | class TestVersion(unittest.TestCase): | ||
| 20 | def test_version(self): | ||
| 21 | proc = subprocess.Popen(['./main.py', '--version'], stdout=subprocess.PIPE) | ||
| 22 | stdout, _ = proc.communicate() | ||
| 23 | self.assertTrue(stdout.startswith(b'MAT2 ')) | ||
| 24 | |||
| 17 | 25 | ||
| 18 | 26 | ||
| 19 | class TestReturnValue(unittest.TestCase): | 27 | class TestReturnValue(unittest.TestCase): |
