Skip to content
Snippets Groups Projects
Commit be6d32af authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Some arguments are mutually exclusives

parent 7b0a27ce
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,7 @@ def create_arg_parser(): ...@@ -30,7 +30,7 @@ def create_arg_parser():
parser.add_argument('-l', '--list', action='store_true', parser.add_argument('-l', '--list', action='store_true',
help='list all supported fileformats') 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', info.add_argument('-c', '--check', action='store_true',
help='check if a file is free of harmful metadatas') help='check if a file is free of harmful metadatas')
info.add_argument('-s', '--show', action='store_true', info.add_argument('-s', '--show', action='store_true',
......
...@@ -8,12 +8,12 @@ class TestHelp(unittest.TestCase): ...@@ -8,12 +8,12 @@ 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] [-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): 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] [-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): class TestVersion(unittest.TestCase):
...@@ -23,6 +23,12 @@ class TestVersion(unittest.TestCase): ...@@ -23,6 +23,12 @@ class TestVersion(unittest.TestCase):
self.assertTrue(stdout.startswith(b'MAT2 ')) 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): class TestReturnValue(unittest.TestCase):
def test_nonzero(self): def test_nonzero(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment