1
0
mirror of synced 2024-12-22 20:59:58 +01:00

Some arguments are mutually exclusives

This commit is contained in:
jvoisin 2018-05-16 00:07:04 +02:00
parent 7b0a27ce76
commit be6d32afa8
2 changed files with 9 additions and 3 deletions

View File

@ -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',

View File

@ -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):