Skip to content

Commit 6fa9a2b

Browse files
committed
add test for boolean type error
1 parent 92cebe7 commit 6fa9a2b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

cwltool/main.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,13 @@ def generate_parser(toolparser, tool, namemap):
285285
_logger.debug(u"Can't make command line argument from %s", inptype)
286286
return None
287287

288-
argument_kwargs = {'required': required, 'help': ahelp, 'action': action, 'default': default}
289288
if inptype != "boolean":
290-
argument_kwargs['type'] = atype
291-
toolparser.add_argument(flag + name, **argument_kwargs)
289+
typekw = { 'type': atype }
290+
else:
291+
typekw = {}
292+
293+
toolparser.add_argument(flag + name, required=required,
294+
help=ahelp, action=action, default=default, **typekw)
292295

293296
return toolparser
294297

tests/test_toolargparse.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,37 @@ class ToolArgparse(unittest.TestCase):
2424
glob: test.txt
2525
stdout: test.txt
2626
baseCommand: [cat]
27+
'''
28+
29+
script2='''
30+
#!/usr/bin/env cwl-runner
31+
cwlVersion: 'cwl:draft-3'
32+
class: CommandLineTool
33+
inputs:
34+
- id: bdg
35+
type: "boolean"
36+
outputs:
37+
- id: output
38+
type: File
39+
outputBinding:
40+
glob: foo
41+
baseCommand:
42+
- echo
43+
- "ff"
44+
stdout: foo
2745
'''
2846

2947
def test_help(self):
3048
with NamedTemporaryFile() as f:
3149
f.write(self.script)
3250
f.flush()
3351
self.assertEquals(main([f.name, '--input', 'README.rst']), 0)
52+
53+
def test_bool(self):
54+
with NamedTemporaryFile() as f:
55+
f.write(self.script2)
56+
f.flush()
57+
try:
58+
self.assertEquals(main([f.name, '--help']), 0)
59+
except SystemExit as e:
60+
self.assertEquals(e.code, 0)

0 commit comments

Comments
 (0)