test.test_transforms.test_transitions.py Maven / Gradle / Ivy
#! /usr/bin/env python
# $Id: test_transitions.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: David Goodger
# Copyright: This module has been placed in the public domain.
"""
Test module for misc.Transitions transform.
"""
from __init__ import DocutilsTestSupport # must be imported before docutils
from docutils.transforms.misc import Transitions
from docutils.parsers.rst import Parser
def suite():
parser = Parser()
s = DocutilsTestSupport.TransformTestSuite(parser)
s.generateTests(totest)
return s
totest = {}
totest['transitions'] = ((Transitions,), [
["""\
Section 1
=========
Subsection 1
------------
Some text.
----------
Section 2
=========
Some text.
""",
"""\
Section 1
Subsection 1
Some text.
Section 2
Some text.
"""],
["""\
A paragraph.
----------
Section 1
=========
Paragraph.
""",
"""\
A paragraph.
Section 1
Paragraph.
"""],
["""\
--------
A section or document may not begin with a transition.
The DTD specifies that two transitions may not
be adjacent:
--------
--------
--------
The DTD also specifies that a section or document
may not end with a transition.
--------
""",
"""\
Document or section may not begin with a transition.
A section or document may not begin with a transition.
The DTD specifies that two transitions may not
be adjacent:
At least one body element must separate transitions; adjacent transitions are not allowed.
At least one body element must separate transitions; adjacent transitions are not allowed.
The DTD also specifies that a section or document
may not end with a transition.
Document may not end with a transition.
"""],
["""\
Sections with transitions at beginning and end.
Section 1
=========
----------
The next transition is legal:
----------
Section 2
=========
----------
""",
"""\
Sections with transitions at beginning and end.
Section 1
Document or section may not begin with a transition.
The next transition is legal:
Section 2
Document or section may not begin with a transition.
Document may not end with a transition.
"""],
["""\
A paragraph and two transitions.
----------
----------
""", # the same:
"""\
A paragraph and two transitions.
At least one body element must separate transitions; adjacent transitions are not allowed.
Document may not end with a transition.
"""],
["""\
A paragraph, two transitions, and a blank line.
----------
----------
""",
"""\
A paragraph, two transitions, and a blank line.
At least one body element must separate transitions; adjacent transitions are not allowed.
Document may not end with a transition.
"""],
["""\
----------
Document beginning with a transition.
""",
"""\
Document or section may not begin with a transition.
Document beginning with a transition.
"""],
["""\
Section 1
=========
----------
----------
----------
Section 2
=========
Some text.
""",
"""\
Section 1
Document or section may not begin with a transition.
At least one body element must separate transitions; adjacent transitions are not allowed.
At least one body element must separate transitions; adjacent transitions are not allowed.
Section 2
Some text.
"""],
["""\
----------
----------
----------
""",
"""\
Document or section may not begin with a transition.
At least one body element must separate transitions; adjacent transitions are not allowed.
At least one body element must separate transitions; adjacent transitions are not allowed.
Document may not end with a transition.
"""],
["""\
A paragraph.
----------
""",
"""\
A paragraph.
Document may not end with a transition.
"""],
])
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')