def test_can_parse_return_type(self): docstring = '\n'.join([ 'Return an approximation of pi.', '', 'Returns:', ' Decimal: An approximation of pi.', ]) doc = Docstring(docstring) self.assertEqual(doc.get_types(Sections.RETURNS_SECTION), 'Decimal')
def test_argument_types_can_be_parsed(self): docstring = '\n'.join([ 'This docstring contains types for its arguments.', '', 'Args:', ' x (int): The first number.', ' y (float): The second number.', ]) doc = Docstring(docstring) arg_types = { name: _type for name, _type in zip( doc.get_items(Sections.ARGUMENTS_SECTION), doc.get_types(Sections.ARGUMENTS_SECTION), ) } self.assertEqual(arg_types['x'], 'int') self.assertEqual(arg_types['y'], 'float')