Skip to content
Snippets Groups Projects
Commit b20a29fa authored by Bienchen's avatar Bienchen
Browse files

Made description mandatory

parent c601a8f6
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ File Tests
(fh, fn) = tempfile.mkstemp(suffix='.pdb')
os.close(fh)
p = pm3argparse.PM3ArgumentParser()
p = pm3argparse.PM3ArgumentParser('Dummy')
p.add_argument('file', type=str)
opts = p.Parse([fn])
......@@ -71,7 +71,7 @@ File Tests
from promod3.core import helper
from promod3.core import pm3argparse
p = pm3argparse.PM3ArgumentParser()
p = pm3argparse.PM3ArgumentParser(__doc__)
p.add_argument('file', type=str)
opts = p.Parse()
......
......@@ -63,10 +63,14 @@ class PM3ArgumentParser(argparse.ArgumentParser):
:type: :class:`bool`
"""
def __init__(self, action=True, description=None):
def __init__(self, description, action=True):
"""
Create a new instance of :class:`~pm3argparse.PM3ArgumentParser`.
:param description: Help text for this script, handed down to
|descattr|_ of |argpinit|_.
:type description: :class:`str`
:param action: Indicates if the calling script is a |project| action.
This influences |progattr|_ of
:class:`~argparse.ArgumentParser` by clipping of the
......@@ -75,10 +79,6 @@ class PM3ArgumentParser(argparse.ArgumentParser):
:class:`~argparse.ArgumentParser` kicks in.
:type action: :class:`bool`
:param description: Help text for this script, handed down to
|descattr|_ of |argpinit|_.
:type description: :class:`str`
:returns: :class:`argparse.ArgumentParser`.
"""
prog = None
......
"""
Testing our own little argument parser.
"""
import unittest
import ost
from promod3.core import pm3argparse
......@@ -30,7 +34,7 @@ class PM3ArgParseTests(unittest.TestCase):
ost.PopLogSink()
def testUnrecognisedArguments(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
with self.assertRaises(SystemExit) as ecd:
parser.Parse(['-x'])
self.assertEqual(ecd.exception.code, 2)
......@@ -40,22 +44,24 @@ class PM3ArgParseTests(unittest.TestCase):
'arguments: -x'])
def testActionSwitch(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--help'])
self.assertEqual(ecd.exception.code, 0)
self.assertEqual(self.log.messages['SCRIPT'],
['usage: test_pm3argparse.py [-h]\n\noptional '+
['usage: test_pm3argparse.py [-h]\n\nTesting our '+
'own little argument parser.\n\noptional '+
'arguments:\n -h, --help show this help message '+
'and exit'])
self.log.messages = dict()
parser = pm3argparse.PM3ArgumentParser(action=True)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=True)
with self.assertRaises(SystemExit) as ecd:
parser.Parse(['--help'])
self.assertEqual(ecd.exception.code, 0)
self.assertEqual(self.log.messages['SCRIPT'],
['usage: t_pm3argparse.py [-h]\n\noptional '+
['usage: t_pm3argparse.py [-h]\n\nTesting our own '+
'little argument parser.\n\noptional '+
'arguments:\n -h, --help show this help message '+
'and exit'])
......@@ -74,7 +80,7 @@ class PM3ArgParseTests(unittest.TestCase):
def testAddAlignemntNoTrgPfx(self):
# checking that we fail on missing 'trg:' prefix for arguments of
# --fasta
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -88,7 +94,7 @@ class PM3ArgParseTests(unittest.TestCase):
def testAddAlignemntEmptyTrgPfx(self):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -101,7 +107,7 @@ class PM3ArgParseTests(unittest.TestCase):
def testAddAlignemntSwapTrgPfx(self):
# checking that we fail on empty 'trg:' prefix for arguments of
# --fasta
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -113,7 +119,7 @@ class PM3ArgParseTests(unittest.TestCase):
def testAddAlignmentNoFile(self):
# check that we throw an error if a non-exisiting file is given
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -124,7 +130,7 @@ class PM3ArgParseTests(unittest.TestCase):
def testAddAlignmentEmpty(self):
# we want to fail if we get an empty FastA file
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -135,7 +141,7 @@ class PM3ArgParseTests(unittest.TestCase):
"wrong format: data/fasta/alignment.fas")
def testAddAlignmentToMany(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -146,7 +152,7 @@ class PM3ArgParseTests(unittest.TestCase):
"more than 2 sequences.")
def testAddAlignmentMissingTargetName(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -157,7 +163,7 @@ class PM3ArgParseTests(unittest.TestCase):
"found in the alignment.")
def testAddAlignmentDifferentSeqLens(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
with self.assertRaises(SystemExit) as ecd:
......@@ -168,7 +174,7 @@ class PM3ArgParseTests(unittest.TestCase):
"alignment have different length.")
def testAddAlignmentGzipIn(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
opts = parser.Parse(['--fasta', 'trg:target',
......@@ -197,7 +203,7 @@ class PM3ArgParseTests(unittest.TestCase):
'YHQMTAPLIGYYYYSKEAEAGNTKYAKVDGTKPV---AEVRADLEK\n')
def testAddAlignmentSwitchSeqs(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
opts = parser.Parse(['--fasta', 'trg:target',
......@@ -209,7 +215,7 @@ class PM3ArgParseTests(unittest.TestCase):
'DDQEETVRKRLVEYHQMTAPLL--YYYYKEAEAGNTKYAKVDGTKPVAEV'+
'RADLEKILG')
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
opts = parser.Parse(['--fasta', 'trg:target',
......@@ -222,7 +228,7 @@ class PM3ArgParseTests(unittest.TestCase):
'RADLEKILG')
def testAddAlignment(self):
parser = pm3argparse.PM3ArgumentParser(action=False)
parser = pm3argparse.PM3ArgumentParser(__doc__, action=False)
parser.AddAlignment()
parser.AssembleParser()
opts = parser.Parse(['--fasta', 'trg:target',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment