Example #1
0
    def test_find_actions_minimal_two_actions(self):
        src = textwrap.dedent('''\
        .. test_step:: 1

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

            This directive is the last node in this rst document.

        .. test_step:: 2

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.
        ''')
        exp_actions = [
            rstsource.RstTestAction(1, "test_step", 1, 6),
            rstsource.RstTestAction(2, "test_step", 8, 11),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #2
0
    def test_find_actions_real_looking_test_steps_section(self):
        src = textwrap.dedent('''\
        Test Steps
        ==========

        .. test_step:: 1

            list files in the volume: ``ls -a /mnt/helloworld``

        .. test_result:: 1

            there are no files, output should be empty.

        .. test_step:: 2

            donec et mollis dolor::

                $ foo --extra sth
                $ bar -vvv

        .. test_result:: 2

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

        .. test_step:: 3

            This one has no matching test result.

        .. test_result:: 4

            And this result has no test step.

            Donec et mollis dolor::

                $ foo --extra sth
                $ bar -vvv

        .. test_step:: 5

            List files in the volume: ``ls -a /mnt/helloworld``

            This is the last step.
        ''')
        exp_actions = [
            rstsource.RstTestAction(1, "test_step", 4, 6),
            rstsource.RstTestAction(1, "test_result", 8, 10),
            rstsource.RstTestAction(2, "test_step", 12, 17),
            rstsource.RstTestAction(2, "test_result", 19, 22),
            rstsource.RstTestAction(3, "test_step", 24, 26),
            rstsource.RstTestAction(4, "test_result", 28, 35),
            rstsource.RstTestAction(5, "test_step", 37, 41),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #3
0
    def test_find_actions_simpledoc_endline_anotherdirective(self):
        src = textwrap.dedent('''\
        Test Steps
        ==========

        .. test_step:: 1

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

            And that's all!

        .. test_step:: 2

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.
        ''')
        exp_actions = [
            rstsource.RstTestAction(1, "test_step", 4, 9),
            rstsource.RstTestAction(2, "test_step", 11, 14),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #4
0
    def test_find_actions_simpledoc_endline_theend(self):
        src = textwrap.dedent('''\
        Test Steps
        ==========

        .. test_step:: 10

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

            This directive is the last node in this rst document.
        ''')
        exp_actions = [
            rstsource.RstTestAction(10, "test_step", 4, 9),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #5
0
    def test_find_actions_simpledoc_endline_paragraph(self):
        src = textwrap.dedent('''\
        Test Steps
        ==========

        .. test_step:: 5

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

            And that's all!

        There is some other text after the directive.
        ''')
        exp_actions = [
            rstsource.RstTestAction(5, "test_step", 4, 9),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #6
0
    def test_find_actions_somedoc_oneaction(self):
        src = textwrap.dedent('''\
        =============
         Test FooBar
        =============

        :author: [email protected]
        :date: 2015-11-06

        Header One
        ==========

        Here is some text.

        .. while this line tries to hide itself

        Achtung
        ```````

        .. test_step:: 1

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

        In this piece of code, we can see a similar issue::

           def foo(bar):
               return False

        Test Steps
        ==========

        There are no rst directives in this section.
        ''')
        exp_actions = [
            rstsource.RstTestAction(1, "test_step", 18, 21),
        ]
        assert rstsource.find_actions(src) == exp_actions
Example #7
0
    def test_find_actions_mixed(self):
        src = textwrap.dedent('''\
        This looks little fishy.

        .. test_step:: 1

            list files in the volume: ``ls -a /mnt/helloworld``

        This just some line. Ignore it.

        .. test_result:: 1

            there are no files, output should be empty.

        And another one! Let's ignore it as well.

        .. test_step:: 2

            donec et mollis dolor::

                $ foo --extra sth
                $ bar -vvv

        Test Steps
        ==========

        This doesn't make any sense.

        .. test_result:: 2

            Maecenas congue ligula ac quam viverra nec
            consectetur ante hendrerit.

        Test Steps Subsection
        `````````````````````

        Yay!

        .. test_step:: 3

            This one has no matching test result.

        .. test_result:: 4

            And this result has no test step.

            Donec et mollis dolor::

                $ foo --extra sth
                $ bar -vvv

        Foo Bar Baz Section
        ===================

        Really, this looks weird. But find_sections() should work anyway.

        .. test_step:: 5

            List files in the volume: ``ls -a /mnt/helloworld``

            This is the last step.
        ''')
        exp_actions = [
            rstsource.RstTestAction(1, "test_step", 3, 5),
            rstsource.RstTestAction(1, "test_result", 9, 11),
            rstsource.RstTestAction(2, "test_step", 15, 20),
            rstsource.RstTestAction(2, "test_result", 27, 30),
            rstsource.RstTestAction(3, "test_step", 37, 39),
            rstsource.RstTestAction(4, "test_result", 41, 48),
            rstsource.RstTestAction(5, "test_step", 55, 59),
        ]
        assert rstsource.find_actions(src) == exp_actions