Beispiel #1
0
 def test_parse_simple_section_cannot_start_with_args(self):
     """Make sure the simple section starts with return or yield."""
     with self.assertRaises(ParserException):
         parse_simple_section(
             Peaker(lex('Args:\n'
                        '    Not a simple section.\n'
                        '\n')))
Beispiel #2
0
 def test_parse_returns_section_with_type(self):
     """Make sure the returns section can have a type."""
     node = parse_simple_section(
         Peaker(lex('Returns:\n'
                    '    int: The square of something.\n'
                    '\n')))
     self.assertEqual(
         node.node_type,
         NodeType.SECTION,
     )
     child_types = [x.node_type for x in node.walk()]
     self.assertEqual(child_types, [
         NodeType.RETURNS,
         NodeType.COLON,
         NodeType.SECTION_HEAD,
         NodeType.INDENT,
         NodeType.WORD,
         NodeType.TYPE,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.LINE,
         NodeType.SECTION_SIMPLE_BODY,
         NodeType.SECTION,
     ])
Beispiel #3
0
 def test_parse_returns_section(self):
     """Make sure can parse returns section."""
     node = parse_simple_section(
         Peaker(lex('Returns:\n'
                    '    A meaningful value.\n'
                    '\n')))
     self.assertEqual(
         node.node_type,
         NodeType.SECTION,
     )
     child_types = [x.node_type for x in node.walk()]
     self.assertEqual(child_types, [
         NodeType.RETURNS,
         NodeType.COLON,
         NodeType.SECTION_HEAD,
         NodeType.INDENT,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.LINE,
         NodeType.SECTION_SIMPLE_BODY,
         NodeType.SECTION,
     ])
Beispiel #4
0
 def test_parse_yields_section(self):
     """Make sure we can parse a yields section."""
     node = parse_simple_section(
         Peaker(lex('Yields:\n'
                    '    Nodes in a stream.\n'
                    '\n')))
     self.assertEqual(
         node.node_type,
         NodeType.SECTION,
     )
     child_types = [x.node_type for x in node.walk()]
     self.assertEqual(child_types, [
         NodeType.YIELDS,
         NodeType.COLON,
         NodeType.SECTION_HEAD,
         NodeType.INDENT,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.WORD,
         NodeType.LINE,
         NodeType.SECTION_SIMPLE_BODY,
         NodeType.SECTION,
     ])