def test_type(self):
     parser, tool = self.get_simple_tool('test-optional.py')
     for action in self._strip_help_version_actions(parser._actions):
         arg_type = tool.inputs[action.dest].type
         if type(
                 arg_type
         ) is list:  # if argument is optional, the first type in list is `null`
             arg_type = arg_type[1]  # the second is the actual type
         if action.choices:
             if type(action.choices) is range:
                 self.assertEqual(list(action.choices), arg_type['symbols'])
             else:
                 self.assertEqual(action.choices, arg_type['symbols'])
             self.assertEqual('enum', arg_type['type'])
         if action.type:
             if isinstance(action.type, argparse.FileType):
                 action_type = 'File'
             else:
                 action_type = ac.get_cwl_type(action.type)
             if (action.nargs and action.nargs != '?') \
                     or type(action).__name__.startswith("_Append"):
                 self.assertEqual('array', arg_type['type'])
                 self.assertEqual(action.items_type or 'string',
                                  arg_type['items'])
             elif action.choices:
                 self.assertTrue(
                     all(
                         isinstance(x, action.type)
                         for x in arg_type['symbols']))
             else:
                 self.assertEqual(action_type, arg_type)
 def test_type(self):
     parser, tool = self.get_simple_tool('test-optional.py')
     for action in self._strip_help_version_actions(parser._actions):
         arg_type = tool.inputs[action.dest].type
         if type(arg_type) is list:  # if argument is optional, the first type in list is `null`
             arg_type = arg_type[1]  # the second is the actual type
         if action.choices:
             if type(action.choices) is range:
                 self.assertEqual(list(action.choices), arg_type['symbols'])
             else:
                 self.assertEqual(action.choices, arg_type['symbols'])
             self.assertEqual('enum', arg_type['type'])
         if action.type:
             if isinstance(action.type, argparse.FileType):
                 action_type = 'File'
             else:
                 action_type = ac.get_cwl_type(action.type)
             if (action.nargs and action.nargs != '?') \
                     or type(action).__name__.startswith("_Append"):
                 self.assertEqual('array', arg_type['type'])
                 self.assertEqual(action.items_type or 'string', arg_type['items'])
             elif action.choices:
                 self.assertTrue(all(isinstance(x, action.type) for x in arg_type['symbols']))
             else:
                 self.assertEqual(action_type, arg_type)
 def test_type_conversions(self):
     self.assertEqual(ac.get_cwl_type(open), 'File')
     self.assertEqual(ac.get_cwl_type(argparse.FileType('r')), 'File')
     self.assertEqual(ac.get_cwl_type(str), 'string')
     self.assertEqual(ac.get_cwl_type('str'), 'string')
 def test_type_conversions(self):
     self.assertEqual(ac.get_cwl_type(open), 'File')
     self.assertEqual(ac.get_cwl_type(argparse.FileType('r')), 'File')
     self.assertEqual(ac.get_cwl_type(str), 'string')
     self.assertEqual(ac.get_cwl_type('str'), 'string')