All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.test_parsers.test_rst.test_literal_blocks.py Maven / Gradle / Ivy

There is a newer version: 2.4
Show newest version
#! /usr/bin/env python

# $Id: test_literal_blocks.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: David Goodger 
# Copyright: This module has been placed in the public domain.

"""
Tests for states.py.
"""

from __init__ import DocutilsTestSupport

def suite():
    s = DocutilsTestSupport.ParserTestSuite()
    s.generateTests(totest)
    return s

totest = {}

totest['indented_literal_blocks'] = [
["""\
A paragraph::

    A literal block.
""",
"""\

    
        A paragraph:
    
        A literal block.
"""],
["""\
A paragraph with a space after the colons:: \n\

    A literal block.
""",
"""\

    
        A paragraph with a space after the colons:
    
        A literal block.
"""],
["""\
A paragraph::

    A literal block.

Another paragraph::

    Another literal block.
    With two blank lines following.


A final paragraph.
""",
"""\

    
        A paragraph:
    
        A literal block.
    
        Another paragraph:
    
        Another literal block.
        With two blank lines following.
    
        A final paragraph.
"""],
["""\
A paragraph
on more than
one line::

    A literal block.
""",
"""\

    
        A paragraph
        on more than
        one line:
    
        A literal block.
"""],
["""\
A paragraph
on more than
one line::
    A literal block
    with no blank line above.
""",
"""\

    
        A paragraph
        on more than
        one line:
    
        
            Unexpected indentation.
    
        A literal block
        with no blank line above.
"""],
["""\
A paragraph::

    A literal block.
no blank line
""",
"""\

    
        A paragraph:
    
        A literal block.
    
        
            Literal block ends without a blank line; unexpected unindent.
    
        no blank line
"""],
[r"""
A paragraph\\::

    A literal block.

A paragraph\::

    Not a literal block.
""",
r"""
    
        A paragraph\:
    
        A literal block.
    
        A paragraph::
    
        
            Not a literal block.
"""],
[r"""
\\::

    A literal block.

\::

    Not a literal block.
""",
r"""
    
        \:
    
        A literal block.
    
        ::
    
        
            Not a literal block.
"""],
["""\
A paragraph: ::

    A literal block.
""",
"""\

    
        A paragraph:
    
        A literal block.
"""],
["""\
A paragraph:

::

    A literal block.
""",
"""\

    
        A paragraph:
    
        A literal block.
"""],
["""\
A paragraph:
::

    A literal block.
""",
"""\

    
        
            Possible title underline, too short for the title.
            Treating it as ordinary text because it's so short.
    
        A paragraph:
    
        A literal block.
"""],
["""\
A paragraph:

::

    A literal block.
""",
"""\

    
        A paragraph:
    
        A literal block.
"""],
["""\
A paragraph::

Not a literal block.
""",
"""\

    
        A paragraph:
    
        
            Literal block expected; none found.
    
        Not a literal block.
"""],
["""\
A paragraph::

    A wonky literal block.
  Literal line 2.

    Literal line 3.
""",
"""\

    
        A paragraph:
    
          A wonky literal block.
        Literal line 2.
        \n\
          Literal line 3.
"""],
["""\
EOF, even though a literal block is indicated::
""",
"""\

    
        EOF, even though a literal block is indicated:
    
        
            Literal block expected; none found.
"""],
]

totest['quoted_literal_blocks'] = [
["""\
A paragraph::

> A literal block.
""",
"""\

    
        A paragraph:
    
        > A literal block.
"""],
["""\
A paragraph::


> A literal block.
""",
"""\

    
        A paragraph:
    
        > A literal block.
"""],
["""\
A paragraph::

> A literal block.
> Line 2.
""",
"""\

    
        A paragraph:
    
        > A literal block.
        > Line 2.
"""],
["""\
A paragraph::

> A literal block.
  Indented line.
""",
"""\

    
        A paragraph:
    
        > A literal block.
    
        
            Unexpected indentation.
    
        
            Indented line.
"""],
["""\
A paragraph::

> A literal block.
Text.
""",
"""\

    
        A paragraph:
    
        > A literal block.
    
        
            Inconsistent literal block quoting.
    
        Text.
"""],
["""\
A paragraph::

> A literal block.
$ Inconsistent line.
""",
"""\

    
        A paragraph:
    
        > A literal block.
    
        
            Inconsistent literal block quoting.
    
        $ Inconsistent line.
"""],
]


if __name__ == '__main__':
    import unittest
    unittest.main(defaultTest='suite')




© 2015 - 2024 Weber Informatics LLC | Privacy Policy