Fix: os.walk patch
[docutils.git] / test / test_transforms / test_sectnum.py
blobf95684581729658adc726dd9c2cd4f5f3298d21d
1 #! /usr/bin/env python
3 # $Id$
4 # Authors: David Goodger <goodger@python.org>; Dmitry Jemerov
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for `docutils.transforms.parts.SectNum` (via
9 `docutils.transforms.universal.LastReaderPending`).
10 """
12 from __init__ import DocutilsTestSupport
13 from docutils.transforms.references import Substitutions
14 from docutils.parsers.rst import Parser
17 def suite():
18 parser = Parser()
19 s = DocutilsTestSupport.TransformTestSuite(parser)
20 s.generateTests(totest)
21 return s
23 totest = {}
25 totest['section_numbers'] = ((Substitutions,), [
26 ["""\
27 .. sectnum::
29 Title 1
30 =======
31 Paragraph 1.
33 Title 2
34 -------
35 Paragraph 2.
37 Title 3
38 ```````
39 Paragraph 3.
41 Title 4
42 -------
43 Paragraph 4.
44 """,
45 u"""\
46 <document source="test data">
47 <section ids="title-1" names="title\ 1">
48 <title auto="1">
49 <generated classes="sectnum">
50 1\u00a0\u00a0\u00a0
51 Title 1
52 <paragraph>
53 Paragraph 1.
54 <section ids="title-2" names="title\ 2">
55 <title auto="1">
56 <generated classes="sectnum">
57 1.1\u00a0\u00a0\u00a0
58 Title 2
59 <paragraph>
60 Paragraph 2.
61 <section ids="title-3" names="title\ 3">
62 <title auto="1">
63 <generated classes="sectnum">
64 1.1.1\u00a0\u00a0\u00a0
65 Title 3
66 <paragraph>
67 Paragraph 3.
68 <section ids="title-4" names="title\ 4">
69 <title auto="1">
70 <generated classes="sectnum">
71 1.2\u00a0\u00a0\u00a0
72 Title 4
73 <paragraph>
74 Paragraph 4.
75 """],
76 ["""\
77 .. sectnum::
79 **Bold Title**
80 ==============
81 Paragraph 1.
82 """,
83 u"""\
84 <document source="test data">
85 <section ids="bold-title" names="bold\ title">
86 <title auto="1">
87 <generated classes="sectnum">
88 1\u00a0\u00a0\u00a0
89 <strong>
90 Bold Title
91 <paragraph>
92 Paragraph 1.
93 """],
94 ["""\
95 .. sectnum:: :depth: 2
97 Title 1
98 =======
99 Paragraph 1.
101 Title 2
102 -------
103 Paragraph 2.
105 Title 3
106 ```````
107 Paragraph 3.
109 Title 4
110 -------
111 Paragraph 4.
112 """,
113 u"""\
114 <document source="test data">
115 <section ids="title-1" names="title\ 1">
116 <title auto="1">
117 <generated classes="sectnum">
118 1\u00a0\u00a0\u00a0
119 Title 1
120 <paragraph>
121 Paragraph 1.
122 <section ids="title-2" names="title\ 2">
123 <title auto="1">
124 <generated classes="sectnum">
125 1.1\u00a0\u00a0\u00a0
126 Title 2
127 <paragraph>
128 Paragraph 2.
129 <section ids="title-3" names="title\ 3">
130 <title>
131 Title 3
132 <paragraph>
133 Paragraph 3.
134 <section ids="title-4" names="title\ 4">
135 <title auto="1">
136 <generated classes="sectnum">
137 1.2\u00a0\u00a0\u00a0
138 Title 4
139 <paragraph>
140 Paragraph 4.
141 """],
142 ["""\
143 .. contents::
144 .. sectnum:: :depth: 2
146 Title 1
147 =======
148 Paragraph 1.
150 Title 2
151 -------
152 Paragraph 2.
154 Title 3
155 ```````
156 Paragraph 3.
158 Title 4
159 -------
160 Paragraph 4.
161 """,
162 u"""\
163 <document source="test data">
164 <topic classes="contents" ids="contents" names="contents">
165 <title>
166 Contents
167 <bullet_list classes="auto-toc">
168 <list_item>
169 <paragraph>
170 <reference ids="id1" refid="title-1">
171 <generated classes="sectnum">
172 1\u00a0\u00a0\u00a0
173 Title 1
174 <bullet_list classes="auto-toc">
175 <list_item>
176 <paragraph>
177 <reference ids="id2" refid="title-2">
178 <generated classes="sectnum">
179 1.1\u00a0\u00a0\u00a0
180 Title 2
181 <bullet_list>
182 <list_item>
183 <paragraph>
184 <reference ids="id3" refid="title-3">
185 Title 3
186 <list_item>
187 <paragraph>
188 <reference ids="id4" refid="title-4">
189 <generated classes="sectnum">
190 1.2\u00a0\u00a0\u00a0
191 Title 4
192 <section ids="title-1" names="title\ 1">
193 <title auto="1" refid="id1">
194 <generated classes="sectnum">
195 1\u00a0\u00a0\u00a0
196 Title 1
197 <paragraph>
198 Paragraph 1.
199 <section ids="title-2" names="title\ 2">
200 <title auto="1" refid="id2">
201 <generated classes="sectnum">
202 1.1\u00a0\u00a0\u00a0
203 Title 2
204 <paragraph>
205 Paragraph 2.
206 <section ids="title-3" names="title\ 3">
207 <title refid="id3">
208 Title 3
209 <paragraph>
210 Paragraph 3.
211 <section ids="title-4" names="title\ 4">
212 <title auto="1" refid="id4">
213 <generated classes="sectnum">
214 1.2\u00a0\u00a0\u00a0
215 Title 4
216 <paragraph>
217 Paragraph 4.
218 """],
219 ["""\
220 .. sectnum::
221 :prefix: Arbitrary-
223 Title 1
224 =======
225 Paragraph 1.
227 Title 2
228 -------
229 Paragraph 2.
231 Title 3
232 ```````
233 Paragraph 3.
235 Title 4
236 -------
237 Paragraph 4.
238 """,
239 u"""\
240 <document source="test data">
241 <section ids="title-1" names="title\ 1">
242 <title auto="1">
243 <generated classes="sectnum">
244 Arbitrary-1\u00a0\u00a0\u00a0
245 Title 1
246 <paragraph>
247 Paragraph 1.
248 <section ids="title-2" names="title\ 2">
249 <title auto="1">
250 <generated classes="sectnum">
251 Arbitrary-1.1\u00a0\u00a0\u00a0
252 Title 2
253 <paragraph>
254 Paragraph 2.
255 <section ids="title-3" names="title\ 3">
256 <title auto="1">
257 <generated classes="sectnum">
258 Arbitrary-1.1.1\u00a0\u00a0\u00a0
259 Title 3
260 <paragraph>
261 Paragraph 3.
262 <section ids="title-4" names="title\ 4">
263 <title auto="1">
264 <generated classes="sectnum">
265 Arbitrary-1.2\u00a0\u00a0\u00a0
266 Title 4
267 <paragraph>
268 Paragraph 4.
269 """],
270 ["""\
271 .. sectnum::
272 :start: 3
274 Title 1
275 =======
276 Paragraph 1.
278 Title 2
279 -------
280 Paragraph 2.
282 Title 3
283 ```````
284 Paragraph 3.
286 Title 4
287 -------
288 Paragraph 4.
289 """,
290 u"""\
291 <document source="test data">
292 <section ids="title-1" names="title\ 1">
293 <title auto="1">
294 <generated classes="sectnum">
295 3\u00a0\u00a0\u00a0
296 Title 1
297 <paragraph>
298 Paragraph 1.
299 <section ids="title-2" names="title\ 2">
300 <title auto="1">
301 <generated classes="sectnum">
302 3.1\u00a0\u00a0\u00a0
303 Title 2
304 <paragraph>
305 Paragraph 2.
306 <section ids="title-3" names="title\ 3">
307 <title auto="1">
308 <generated classes="sectnum">
309 3.1.1\u00a0\u00a0\u00a0
310 Title 3
311 <paragraph>
312 Paragraph 3.
313 <section ids="title-4" names="title\ 4">
314 <title auto="1">
315 <generated classes="sectnum">
316 3.2\u00a0\u00a0\u00a0
317 Title 4
318 <paragraph>
319 Paragraph 4.
320 """],
321 ["""\
322 .. sectnum::
323 :prefix: (5.9.
324 :suffix: )
325 :start: 3
327 Title 1
328 =======
329 Paragraph 1.
331 Title 2
332 -------
333 Paragraph 2.
335 Title 3
336 ```````
337 Paragraph 3.
339 Title 4
340 -------
341 Paragraph 4.
342 """,
343 u"""\
344 <document source="test data">
345 <section ids="title-1" names="title\ 1">
346 <title auto="1">
347 <generated classes="sectnum">
348 (5.9.3)\u00a0\u00a0\u00a0
349 Title 1
350 <paragraph>
351 Paragraph 1.
352 <section ids="title-2" names="title\ 2">
353 <title auto="1">
354 <generated classes="sectnum">
355 (5.9.3.1)\u00a0\u00a0\u00a0
356 Title 2
357 <paragraph>
358 Paragraph 2.
359 <section ids="title-3" names="title\ 3">
360 <title auto="1">
361 <generated classes="sectnum">
362 (5.9.3.1.1)\u00a0\u00a0\u00a0
363 Title 3
364 <paragraph>
365 Paragraph 3.
366 <section ids="title-4" names="title\ 4">
367 <title auto="1">
368 <generated classes="sectnum">
369 (5.9.3.2)\u00a0\u00a0\u00a0
370 Title 4
371 <paragraph>
372 Paragraph 4.
373 """],
377 if __name__ == '__main__':
378 import unittest
379 unittest.main(defaultTest='suite')