Add <target> to one more testcase (see r8206).
[docutils.git] / sandbox / texinfo-writer / test_texinfo.py
blobe5adbb36b4c5311545dcf82f631370f2fa0f7475
1 #! /usr/bin/env python
3 # Author: Jon Waltman <jonathan.waltman@gmail.com>
4 # Copyright: This module has been placed in the public domain.
6 """
7 Tests for Texinfo writer.
8 """
10 import os
11 import os.path
12 import sys
14 import texinfo
16 sys.path.insert(0, os.path.abspath('../../docutils/test'))
17 import DocutilsTestSupport
19 def suite():
20 settings = {}
21 s = DocutilsTestSupport.PublishTestSuite('texinfo', suite_settings=settings)
22 s.generateTests(totest)
23 return s
25 template = texinfo.TEMPLATE
27 parts = dict(
28 filename='<string>.info',
29 direntry='',
30 title='<untitled>',
31 paragraphindent='2',
32 exampleindent='4',
33 preamble='',
34 body='\n',
37 totest = {}
39 totest['blank'] = [
40 # input
41 ["",
42 ## # expected output
43 template % dict(parts)],
47 totest['escaping'] = [
48 # input
49 [r"""
50 Escaping -- @,{}:
51 *****************
53 @commands{ use braces }.
55 @ { } @@ {{ }}
57 @} @@}}
59 @{ @@{{
61 """,
62 ## # expected output
63 template % dict(parts,
64 title='Escaping --',
65 body=
66 r"""@@commands@{ use braces @}.
68 @@ @{ @} @@@@ @{@{ @}@}
70 @@@} @@@@@}@}
72 @@@{ @@@@@{@{
73 """)],
78 totest['table_with_markup'] = [
79 # input
80 [r"""
81 +------------+---------------------+--------------------+
82 | emphasis | strong emphasis | inline literal |
83 +============+=====================+====================+
84 | *emphasis* | **strong emphasis** | ``inline literal`` |
85 +------------+---------------------+--------------------+
86 """,
87 ## # expected output
88 template % dict(parts,
89 body=
90 r"""@multitable {xxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
91 @headitem emphasis
92 @tab strong emphasis
93 @tab inline literal
94 @item @emph{emphasis}
95 @tab @strong{strong emphasis}
96 @tab @code{inline literal}
97 @end multitable
98 """)],
101 totest['sections'] = [
102 # input
103 [r"""
107 This tests sectioning.
109 Section 1
110 =========
112 SubSection 1.1
113 --------------
115 SubSubSection 1.1.1
116 ~~~~~~~~~~~~~~~~~~~
118 Section 2
119 =========
121 """,
122 ## # expected output
123 template % dict(parts,
124 title='Top',
125 body=
126 r"""This tests sectioning.
129 @menu
130 * Section 1::
131 * Section 2::
133 @detailmenu
134 --- The Detailed Node Listing ---
136 Section 1
138 * SubSection 1 1::
139 @end detailmenu
140 @end menu
143 @node Section 1,Section 2,Top,Top
144 @anchor{section 1}@anchor{0}@anchor{section-1}
145 @chapter Section 1
147 @menu
148 * SubSection 1 1::
149 @end menu
152 @node SubSection 1 1,,,Section 1
153 @anchor{subsection 1 1}@anchor{1}@anchor{subsection-1-1}
154 @section SubSection 1.1
156 @menu
157 * SubSubSection 1 1 1::
158 @end menu
161 @node SubSubSection 1 1 1,,,SubSection 1 1
162 @anchor{subsubsection 1 1 1}@anchor{2}@anchor{subsubsection-1-1-1}
163 @subsection SubSubSection 1.1.1
165 @node Section 2,,Section 1,Top
166 @anchor{section 2}@anchor{3}@anchor{section-2}
167 @chapter Section 2
168 """)],
171 totest['duplicate_sections'] = [
172 # input
173 [r"""
174 Duplicate
175 =========
177 Duplicate
178 =========
180 Duplicate
181 =========
183 """,
184 ## # expected output
185 template % dict(parts,
186 title='Duplicate',
187 body=
188 r"""@menu
189 * Duplicate: Duplicate<2>.
190 * Duplicate: Duplicate<3>.
191 @end menu
194 @node Duplicate<2>,Duplicate<3>,Top,Top
195 @anchor{duplicate<2>}@anchor{0}@anchor{1}@anchor{id1}
196 @unnumbered Duplicate
198 @node Duplicate<3>,,Duplicate<2>,Top
199 @anchor{duplicate<3>}@anchor{2}@anchor{id2}
200 @unnumbered Duplicate
201 """)],
205 totest['comments'] = [
206 # input
207 [r"""
208 .. Foo
211 """,
212 ## # expected output
213 template % dict(parts,
214 body=
215 r"""@c Foo
216 @c bar
217 """)],
220 totest['docinfo'] = [
221 # input
222 [r"""
223 Doc Info Test
224 =============
226 :Author: Jon
227 :Copyright: This document has been placed in the public domain.
229 Example...
230 """,
231 ## # expected output
232 template % dict(parts,
233 title='Doc Info Test',
234 body=
235 r"""@itemize @w
236 @item Author:
239 @item Copyright:
240 This document has been placed in the public domain.
241 @end itemize
243 Example...
244 """)],
248 totest['admonitions'] = [
249 # input
250 [r"""
251 Admonitions
252 ===========
254 .. Note::
256 Hooty hoo!
258 """,
259 ## # expected output
260 template % dict(parts,
261 title='Admonitions',
262 body=
263 r"""@cartouche
264 @quotation Note
265 Hooty hoo!
266 @end quotation
267 @end cartouche
268 """)],
272 if __name__ == '__main__':
273 import unittest
274 unittest.main(defaultTest='suite')