diff --git a/core/tests/test_pm3argparse.py b/core/tests/test_pm3argparse.py index c8c54c5924c72a435fc1ee48a76bb1e5e11037f9..948d20f116f10c8689aac474f1541167907ba1ca 100644 --- a/core/tests/test_pm3argparse.py +++ b/core/tests/test_pm3argparse.py @@ -77,6 +77,32 @@ class PM3ArgParseTests(unittest.TestCase): 'test.\n\noptional arguments:\n -h, --help show '+ 'this help message and exit']) + def testAddAlignmentNoTrgArg(self): + # check failure on missing trg: argument + parser = pm3argparse.PM3ArgumentParser(__doc__, action=False) + parser.AddAlignment() + parser.AssembleParser() + with self.assertRaises(SystemExit) as ecd: + parser.Parse(['--fasta', 'data/fasta/alignment.fas']) + self.assertEqual(ecd.exception.code, 2) + self.assertEqual(self.log.messages['ERROR'], + ['usage: test_pm3argparse.py [-h] [-f trg:<NAME> '+ + '<FILE>]', 'test_pm3argparse.py: error: argument '+ + '-f/--fasta: expected 2 argument(s)']) + + def testAddAlignmentNoFileArg(self): + # check failure on missing file argument + parser = pm3argparse.PM3ArgumentParser(__doc__, action=False) + parser.AddAlignment() + parser.AssembleParser() + with self.assertRaises(SystemExit) as ecd: + parser.Parse(['--fasta', 'trg:target']) + self.assertEqual(ecd.exception.code, 2) + self.assertEqual(self.log.messages['ERROR'], + ['usage: test_pm3argparse.py [-h] [-f trg:<NAME> '+ + '<FILE>]', 'test_pm3argparse.py: error: argument '+ + '-f/--fasta: expected 2 argument(s)']) + def testAddAlignemntNoTrgPfx(self): # checking that we fail on missing 'trg:' prefix for arguments of # --fasta