Example #1
0
    def test_find_sections_metadata_simple_wrong(self):
        src = textwrap.dedent('''\
        Hello World Test Case
        *********************

        :author: [email protected]
        :date: 2015-11-06
        :comment: This is here just to test metadata processing.

        Section One
        ***********

        Foo.

        Section Two
        ***********

        Bar.
        ''')
        exp_sections = [
            rstsource.RstSection("Hello World Test Case", 1, 6),
            rstsource.RstSection('Section One', 8, 11),
            rstsource.RstSection('Section Two', 13, 16),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #2
0
    def test_find_sections_multilevel_startswithline(self):
        src = textwrap.dedent('''\
        Having some text like this before any title will make this rst
        document to lack a title.

        ===============
         Status Report
        ===============

        Lieber ein Spatz in der Hand als eine Taube auf dem Dach.

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

        Here is some text.

        .. while this line tries to hide itself

        Achtung
        ```````

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

           def foo(bar):
               return False

        Header Two
        ==========

        And here we have some text again.
        ''')
        exp_sections = [
            rstsource.RstSection("Status Report", 5, 28),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #3
0
    def test_find_sections_simpledoc(self):
        src = textwrap.dedent('''\
        Section One
        ***********

        Foo.

        Section Two
        ***********

        Bar.
        ''')
        exp_sections = [
            rstsource.RstSection("Section One", 1, 4),
            rstsource.RstSection("Section Two", 6, 9),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #4
0
    def test_find_sections_metadata_with_other_sections_one(self):
        src = textwrap.dedent('''\
        Just Another Test Case
        **********************

        :author: [email protected]

        Description
        ===========

        Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique
        vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies.
        ''')
        exp_sections = [
            rstsource.RstSection('Description', 6, 10),
            rstsource.RstSection(None, 1, 4),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #5
0
    def test_find_sections_metadata_simple_two(self):
        src = textwrap.dedent('''\
        Just Another Test Case
        **********************

        :author: [email protected]
        ''')
        exp_sections = [
            rstsource.RstSection(None, 1, 4),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #6
0
    def test_find_sections_docwithoutsections_one(self):
        src = textwrap.dedent('''\
        Hello World
        ***********

        There are no sections, just a document title.
        But in this case, it's evaluated as a section, so that
        we are able to detect section fragments.
        ''')
        exp_sections = [
            rstsource.RstSection("Hello World", 1, 6),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #7
0
    def test_find_sections_multilevel_with_testmetadata(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
        ```````

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

           def foo(bar):
               return False

        Header Two
        ==========

        And here we have some text again.

        Header Three
        ============
        ''')
        exp_sections = [
            rstsource.RstSection("Header One", 8, 21),
            rstsource.RstSection("Header Two", 23, 26),
            rstsource.RstSection("Header Three", 28, 29),
            rstsource.RstSection(None, 1, 6),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #8
0
    def test_find_sections_multilevel(self):
        src = textwrap.dedent('''\
        ===============
         Status Report
        ===============

        Lieber ein Spatz in der Hand als eine Taube auf dem Dach.

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

        Here is some text.

        .. while this line tries to hide itself

        Achtung
        ```````

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

           def foo(bar):
               return False

        Header Two
        ==========

        And here we have some text again.

        Header Three
        ============
        ''')
        exp_sections = [
            rstsource.RstSection("Header One", 7, 20),
            rstsource.RstSection("Header Two", 22, 25),
            rstsource.RstSection("Header Three", 27, 28),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #9
0
    def test_find_sections_metadata_simple_one(self):
        src = textwrap.dedent('''\
        Hello World Test Case
        *********************

        :author: [email protected]
        :date: 2015-11-06
        :comment: This is here just to test metadata processing.


        ''')
        exp_sections = [
            rstsource.RstSection(None, 1, 8),
        ]
        assert rstsource.find_sections(src) == exp_sections
Example #10
0
    def test_find_sections_docwithoutsections_one_another(self):
        """
        The same case as test_find_sections_docwithoutsections_one.
        """
        src = textwrap.dedent('''\
        Description
        ===========

        This is just demonstration of usage of pylatest rst directives and
        expected structure of rst document.

        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam
        lectus.  Sed sit amet ipsum mauris. Maecenas congue ligula ac quam
        viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent
        et diam eget libero egestas mattis sit amet vitae augue.

        See :RHBZ:`439858` for more details.
        ''')
        exp_sections = [
            rstsource.RstSection(TestCaseDoc.DESCR.title, 1, 12),
        ]
        assert rstsource.find_sections(src) == exp_sections