Add a --version
option
This commit is contained in:
parent
ef956e84d6
commit
c037e265c6
3
main.py
3
main.py
@ -10,6 +10,7 @@ import multiprocessing
|
|||||||
|
|
||||||
from src import parser_factory
|
from src import parser_factory
|
||||||
|
|
||||||
|
__version__ = '0.1'
|
||||||
|
|
||||||
def __check_file(filename:str, mode:int = os.R_OK) -> bool:
|
def __check_file(filename:str, mode:int = os.R_OK) -> bool:
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
@ -24,6 +25,8 @@ def __check_file(filename:str, mode:int = os.R_OK) -> bool:
|
|||||||
def create_arg_parser():
|
def create_arg_parser():
|
||||||
parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2')
|
parser = argparse.ArgumentParser(description='Metadata anonymisation toolkit 2')
|
||||||
parser.add_argument('files', nargs='*')
|
parser.add_argument('files', nargs='*')
|
||||||
|
parser.add_argument('-v', '--version', action='version',
|
||||||
|
version='MAT2 %s' % __version__)
|
||||||
|
|
||||||
info = parser.add_argument_group('Information')
|
info = parser.add_argument_group('Information')
|
||||||
info.add_argument('-c', '--check', action='store_true',
|
info.add_argument('-c', '--check', action='store_true',
|
||||||
|
@ -8,12 +8,20 @@ class TestHelp(unittest.TestCase):
|
|||||||
def test_help(self):
|
def test_help(self):
|
||||||
proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE)
|
proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE)
|
||||||
stdout, _ = proc.communicate()
|
stdout, _ = proc.communicate()
|
||||||
self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
|
self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
|
||||||
|
|
||||||
def test_no_arg(self):
|
def test_no_arg(self):
|
||||||
proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE)
|
proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE)
|
||||||
stdout, _ = proc.communicate()
|
stdout, _ = proc.communicate()
|
||||||
self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
|
self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
|
||||||
|
|
||||||
|
|
||||||
|
class TestVersion(unittest.TestCase):
|
||||||
|
def test_version(self):
|
||||||
|
proc = subprocess.Popen(['./main.py', '--version'], stdout=subprocess.PIPE)
|
||||||
|
stdout, _ = proc.communicate()
|
||||||
|
self.assertTrue(stdout.startswith(b'MAT2 '))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestReturnValue(unittest.TestCase):
|
class TestReturnValue(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user