Commit be6d32af authored by jvoisin's avatar jvoisin

Some arguments are mutually exclusives

parent 7b0a27ce
......@@ -30,7 +30,7 @@ def create_arg_parser():
parser.add_argument('-l', '--list', action='store_true',
help='list all supported fileformats')
info = parser.add_argument_group('Information')
info = parser.add_mutually_exclusive_group()
info.add_argument('-c', '--check', action='store_true',
help='check if a file is free of harmful metadatas')
info.add_argument('-s', '--show', action='store_true',
......
......@@ -8,12 +8,12 @@ class TestHelp(unittest.TestCase):
def test_help(self):
proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout)
def test_no_arg(self):
proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
self.assertIn(b'usage: main.py [-h] [-v] [-c] [-l] [-s] [-L] [files [files ...]]', stdout)
self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout)
class TestVersion(unittest.TestCase):
......@@ -23,6 +23,12 @@ class TestVersion(unittest.TestCase):
self.assertTrue(stdout.startswith(b'MAT2 '))
class TestExclusiveArgs(unittest.TestCase):
def test_version(self):
proc = subprocess.Popen(['./main.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
self.assertIn(b'main.py: error: argument -c/--check: not allowed with argument -s/--show', stderr)
class TestReturnValue(unittest.TestCase):
def test_nonzero(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment