Regression Testing for epytext
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These tests were taken pretty much verbatim out of the old unittests
from epydoc 2.1.  They could use some serious updating, when I get the
time, esp. given that it's so much easier to write tests with doctest
than it was with unittest.

    >>> from pydoctor.test.epydoc.test_epytext import parse
    >>> import re
    >>> def testparse(s):
    ...     out = parse(s)
    ...     # This is basically word-wrapping:
    ...     out = re.sub(r'((</\w+>)+)', r'\1\n', out).rstrip()
    ...     out = re.sub(r'(?m)^(.{50,70}>)(.)', r'\1\n\2', out).rstrip()
    ...     return out

Paragraphs:

    >>> print(testparse("""
    ...     this is one paragraph.
    ...
    ...     This is
    ...     another.
    ...
    ...     This is a third"""))
    <para>this is one paragraph.</para>
    <para>This is another.</para>
    <para>This is a third</para>

Make sure that unindented fields are allowed:

    >>> print(testparse("""
    ...     This is a paragraph.
    ...
    ...     @foo: This is a field."""))
    <para>This is a paragraph.</para>
    <fieldlist><field lineno='3'><tag>foo</tag>
    <para>This is a field.</para></field></fieldlist>

    >>> print(testparse("""
    ...     This is a paragraph.
    ...     @foo: This is a field."""))
    <para>This is a paragraph.</para>
    <fieldlist><field lineno='2'><tag>foo</tag>
    <para>This is a field.</para></field></fieldlist>

    >>> print(testparse("""
    ...     This is a paragraph.
    ...       @foo: This is a field.
    ...         Hello."""))
    <para>This is a paragraph.</para>
    <fieldlist><field lineno='2'><tag>foo</tag>
    <para>This is a field. Hello.</para></field></fieldlist>

    >>> print(testparse("""Paragraph\n@foo: field"""))
    <para>Paragraph</para>
    <fieldlist><field lineno='1'><tag>foo</tag>
    <para>field</para></field></fieldlist>

    >>> print(testparse("""Paragraph\n\n@foo: field"""))
    <para>Paragraph</para>
    <fieldlist><field lineno='2'><tag>foo</tag>
    <para>field</para></field></fieldlist>

    >>> print(testparse("""\nParagraph\n@foo: field"""))
    <para>Paragraph</para>
    <fieldlist><field lineno='2'><tag>foo</tag>
    <para>field</para></field></fieldlist>

Make sure thta unindented lists are not allowed:

    >>> print(testparse("""
    ...     This is a paragraph.
    ...
    ...     - This is a list item."""))
    Traceback (most recent call last):
    StructuringError: Line 4: Lists must be indented.

    >>> print(testparse("""
    ...     This is a paragraph.
    ...     - This is a list item."""))
    Traceback (most recent call last):
    StructuringError: Line 3: Lists must be indented.

    >>> print(testparse("""
    ...     This is a paragraph.
    ...       - This is a list item.
    ...         Hello.
    ...         - Sublist item"""))
    Traceback (most recent call last):
    StructuringError: Line 5: Lists must be indented.

    >>> print(testparse("""
    ...     This is a paragraph.
    ...       - This is a list item.
    ...         Hello.
    ...
    ...         - Sublist item"""))
    Traceback (most recent call last):
    StructuringError: Line 6: Lists must be indented.

    >>> print(testparse("""Paragraph\n\n- list item"""))
    Traceback (most recent call last):
    StructuringError: Line 3: Lists must be indented.

    >>> print(testparse("""\nParagraph\n- list item"""))
    Traceback (most recent call last):
    StructuringError: Line 3: Lists must be indented.

Special case if there's text on the same line as the opening quote:

    >>> print(testparse("""Paragraph\n- list item"""))
    <para>Paragraph</para>
    <ulist><li><para>list item</para></li></ulist>

Make sure that indented lists are allowed:

    >>> print(testparse('This is a paragraph.\n  - This is a list item.\n'+
    ...           'This is a paragraph'))
    <para>This is a paragraph.</para>
    <ulist><li><para>This is a list item.</para></li></ulist>
    <para>This is a paragraph</para>

    >>> print(testparse('This is a paragraph.\n\n  - This is a list item.'+
    ...           '\n\nThis is a paragraph'))
    <para>This is a paragraph.</para>
    <ulist><li><para>This is a list item.</para></li></ulist>
    <para>This is a paragraph</para>

    >>> print(testparse("""
    ...     This is a paragraph.
    ...
    ...       - This is a list item.
    ...
    ...     This is a paragraph"""))
    <para>This is a paragraph.</para>
    <ulist><li><para>This is a list item.</para></li></ulist>
    <para>This is a paragraph</para>

    >>> print(testparse("""
    ...     This is a paragraph.
    ...
    ...           - This is a list item.
    ...     This is a paragraph"""))
    <para>This is a paragraph.</para>
    <ulist><li><para>This is a list item.</para></li></ulist>
    <para>This is a paragraph</para>

    >>> print(testparse("""
    ...       - This is a list item."""))
    <ulist><li><para>This is a list item.</para></li></ulist>

    >>> print(testparse("""- This is a list item."""))
    <ulist><li><para>This is a list item.</para></li></ulist>

    >>> print(testparse("""\n- This is a list item."""))
    <ulist><li><para>This is a list item.</para></li></ulist>
