4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
8 Tests for docutils.transforms.frontmatter.DocTitle.
11 from __init__
import DocutilsTestSupport
12 from docutils
.transforms
.frontmatter
import DocTitle
, SectionSubTitle
13 from docutils
.parsers
.rst
import Parser
18 s
= DocutilsTestSupport
.TransformTestSuite(parser
)
19 s
.generateTests(totest
)
24 totest
['section_headers'] = ((DocTitle
, SectionSubTitle
), [
26 .. test title promotion
34 <document ids="title" names="title" source="test data" title="Title">
37 <comment xml:space="preserve">
45 Paragraph (no blank line).
48 <document ids="title" names="title" source="test data" title="Title">
52 Paragraph (no blank line).
63 <document source="test data">
66 <section ids="title" names="title">
79 .. title:: Another Title
81 Test title, subtitle, and title metadata.
84 <document ids="title" names="title" source="test data" title="Another Title">
87 <subtitle ids="subtitle" names="subtitle">
90 Test title, subtitle, and title metadata.
99 <document ids="title" names="title" source="test data" title="Title">
102 <system_message level="2" line="2" source="test data" type="WARNING">
104 Title underline too short.
105 <literal_block xml:space="preserve">
109 Test short underline.
116 Test long title and space normalization.
117 The system_message should move after the document title
118 (it was before the beginning of the section).
121 <document ids="long-title" names="long\ title" source="test data" title="Long Title">
124 <system_message level="2" line="1" source="test data" type="WARNING">
126 Title overline too short.
127 <literal_block xml:space="preserve">
132 Test long title and space normalization.
133 The system_message should move after the document title
134 (it was before the beginning of the section).
137 .. Test multiple second-level titles.
152 <document ids="title-1" names="title\ 1" source="test data" title="Title 1">
155 <comment xml:space="preserve">
156 Test multiple second-level titles.
159 <section ids="title-2" names="title\ 2">
164 <section ids="title-3" names="title\ 3">
171 .. |foo| replace:: bar
173 .. _invisible target:
177 This title should be the document title despite the
178 substitution_definition.
181 <document ids="title" names="title" source="test data" title="Title">
184 <substitution_definition names="foo">
186 <target ids="invisible-target" names="invisible\ target">
188 This title should be the document title despite the
189 substitution_definition.
192 (Because of this paragraph, the following is not a doc title.)
210 <document source="test data">
212 (Because of this paragraph, the following is not a doc title.)
213 <section ids="section-title" names="section\ title">
216 <subtitle ids="subtitle" names="subtitle">
218 <section ids="another-section" names="another\ section">
221 <subtitle ids="another-subtitle" names="another\ subtitle">
227 if __name__
== '__main__':
229 unittest
.main(defaultTest
='suite')