diff --git a/main.py b/main.py index f3d8d60..0cda955 100755 --- a/main.py +++ b/main.py @@ -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', diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 67b56eb..864ee0d 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -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):