translations de: pull-quote = Seitenansprache, use utf8 for umlauts
[docutils.git] / test / test_transforms / test_doctitle.py
blob0807bce70b180e19bee8aba849c518f9f7ba143e
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for docutils.transforms.frontmatter.DocTitle.
9 """
11 from __init__ import DocutilsTestSupport
12 from docutils.transforms.frontmatter import DocTitle, SectionSubTitle
13 from docutils.parsers.rst import Parser
16 def suite():
17 parser = Parser()
18 s = DocutilsTestSupport.TransformTestSuite(parser)
19 s.generateTests(totest)
20 return s
22 totest = {}
24 totest['section_headers'] = ((DocTitle, SectionSubTitle), [
25 ["""\
26 .. test title promotion
28 Title
29 =====
31 Paragraph.
32 """,
33 """\
34 <document ids="title" names="title" source="test data" title="Title">
35 <title>
36 Title
37 <comment xml:space="preserve">
38 test title promotion
39 <paragraph>
40 Paragraph.
41 """],
42 ["""\
43 Title
44 =====
45 Paragraph (no blank line).
46 """,
47 """\
48 <document ids="title" names="title" source="test data" title="Title">
49 <title>
50 Title
51 <paragraph>
52 Paragraph (no blank line).
53 """],
54 ["""\
55 Paragraph.
57 Title
58 =====
60 Paragraph.
61 """,
62 """\
63 <document source="test data">
64 <paragraph>
65 Paragraph.
66 <section ids="title" names="title">
67 <title>
68 Title
69 <paragraph>
70 Paragraph.
71 """],
72 ["""\
73 Title
74 =====
76 Subtitle
77 --------
79 .. title:: Another Title
81 Test title, subtitle, and title metadata.
82 """,
83 """\
84 <document ids="title" names="title" source="test data" title="Another Title">
85 <title>
86 Title
87 <subtitle ids="subtitle" names="subtitle">
88 Subtitle
89 <paragraph>
90 Test title, subtitle, and title metadata.
91 """],
92 ["""\
93 Title
94 ====
96 Test short underline.
97 """,
98 """\
99 <document ids="title" names="title" source="test data" title="Title">
100 <title>
101 Title
102 <system_message level="2" line="2" source="test data" type="WARNING">
103 <paragraph>
104 Title underline too short.
105 <literal_block xml:space="preserve">
106 Title
107 ====
108 <paragraph>
109 Test short underline.
110 """],
111 ["""\
112 =======
113 Long Title
114 =======
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).
119 """,
120 """\
121 <document ids="long-title" names="long\ title" source="test data" title="Long Title">
122 <title>
123 Long Title
124 <system_message level="2" line="1" source="test data" type="WARNING">
125 <paragraph>
126 Title overline too short.
127 <literal_block xml:space="preserve">
128 =======
129 Long Title
130 =======
131 <paragraph>
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).
135 """],
136 ["""\
137 .. Test multiple second-level titles.
139 Title 1
140 =======
141 Paragraph 1.
143 Title 2
144 -------
145 Paragraph 2.
147 Title 3
148 -------
149 Paragraph 3.
150 """,
151 """\
152 <document ids="title-1" names="title\ 1" source="test data" title="Title 1">
153 <title>
154 Title 1
155 <comment xml:space="preserve">
156 Test multiple second-level titles.
157 <paragraph>
158 Paragraph 1.
159 <section ids="title-2" names="title\ 2">
160 <title>
161 Title 2
162 <paragraph>
163 Paragraph 2.
164 <section ids="title-3" names="title\ 3">
165 <title>
166 Title 3
167 <paragraph>
168 Paragraph 3.
169 """],
170 ["""\
171 .. |foo| replace:: bar
173 .. _invisible target:
175 Title
176 =====
177 This title should be the document title despite the
178 substitution_definition.
179 """,
180 """\
181 <document ids="title" names="title" source="test data" title="Title">
182 <title>
183 Title
184 <substitution_definition names="foo">
186 <target ids="invisible-target" names="invisible\ target">
187 <paragraph>
188 This title should be the document title despite the
189 substitution_definition.
190 """],
191 ["""\
192 (Because of this paragraph, the following is not a doc title.)
194 ===============
195 Section Title
196 ===============
198 Subtitle
199 ========
201 -----------------
202 Another Section
203 -----------------
205 Another Subtitle
206 ----------------
208 """,
209 """\
210 <document source="test data">
211 <paragraph>
212 (Because of this paragraph, the following is not a doc title.)
213 <section ids="section-title" names="section\ title">
214 <title>
215 Section Title
216 <subtitle ids="subtitle" names="subtitle">
217 Subtitle
218 <section ids="another-section" names="another\ section">
219 <title>
220 Another Section
221 <subtitle ids="another-subtitle" names="another\ subtitle">
222 Another Subtitle
223 """],
227 if __name__ == '__main__':
228 import unittest
229 unittest.main(defaultTest='suite')