Example #1
0
 def test_section_node(self):
     paragraph = nodes.Paragraph(nodes.Text("Hello "),
                                 nodes.Strong("world!"))
     paragraph2 = nodes.Paragraph(nodes.Text("Hello again"))
     node = nodes.Section(
         paragraph,
         paragraph2,
         title="I'm a section",
     )
     assert node.tagname == "Section"
     assert node.options["title"] == "I'm a section"
     assert node.text() == "Hello world!\n\nHello again"
     repr = ("<Section I'm a section: "
             '[<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>, '
             '<Paragraph: [<Text: "Hello again">]>]>')
     assert str(node) == repr
Example #2
0
    def test_paragraph_node(self):
        node = nodes.Paragraph(
            children=[nodes.Text("Hello "),
                      nodes.Strong("world!")])
        assert node.tagname == "Paragraph"
        assert node.text() == "Hello world!"
        assert str(
            node) == '<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>'

        for child in node.children:
            assert child.parent is node
Example #3
0
    def test_section_node(self):
        paragraph = nodes.Paragraph(
            children=[nodes.Text("Hello "),
                      nodes.Strong("world!")])
        paragraph2 = nodes.Paragraph(children=[nodes.Text("Hello again")])
        node = nodes.Section(
            children=[
                paragraph,
                paragraph2,
            ],
            attributes=dict(title="I'm a section"),
        )
        assert node.tagname == "Section"
        assert node.attributes.title == "I'm a section"
        assert node.text() == "Hello world!\n\nHello again"
        repr = ("<Section I'm a section: "
                '[<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>, '
                '<Paragraph: [<Text: "Hello again">]>]>')
        assert str(node) == repr

        for child in node.children:
            assert child.parent is node
Example #4
0
 def test_admonition_node(self, type):
     paragraph = nodes.Paragraph(nodes.Text("Hello "), nodes.Strong("world!"))
     node = nodes.Admonition(
         paragraph,
         title="Hey!",
         type=type,
     )
     assert node.tagname == "Admonition"
     assert node.options.title == "Hey!"
     assert node.options.type == type
     assert node.text() == "Hello world!"
     repr = (
         '<Admonition Hey!: [<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>]>'
     )
     assert str(node) == repr
Example #5
0
 def test_admonition_node(self, type):
     paragraph = nodes.Paragraph(
         children=[nodes.Text("Hello "),
                   nodes.Strong("world!")])
     node = nodes.Admonition(
         children=[paragraph],
         attributes=dict(
             title="Hey!",
             type=type,
         ),
     )
     assert node.tagname == "Admonition"
     assert node.attributes.title == "Hey!"
     assert node.attributes.type == type
     assert node.text() == "Hello world!"
     repr = (
         '<Admonition Hey!: [<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>]>'
     )
     assert str(node) == repr
Example #6
0
 def test_paragraph_node(self):
     node = nodes.Paragraph(nodes.Text("Hello "), nodes.Strong("world!"))
     assert node.tagname == "Paragraph"
     assert node.text() == "Hello world!"
     assert str(
         node) == '<Paragraph: [<Text: "Hello ">, <Strong: "world!">]>'