Spelling fixes
[docutils.git] / test / test_parsers / test_rst / test_footnotes.py
blob1d689ad9268327fbeb1a6a2263c1f02dd4e18c00
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 states.py.
9 """
11 from __init__ import DocutilsTestSupport
13 def suite():
14 s = DocutilsTestSupport.ParserTestSuite()
15 s.generateTests(totest)
16 return s
18 totest = {}
20 totest['footnotes'] = [
21 ["""\
22 .. [1] This is a footnote.
23 """,
24 """\
25 <document source="test data">
26 <footnote ids="id1" names="1">
27 <label>
29 <paragraph>
30 This is a footnote.
31 """],
32 ["""\
33 .. [1] This is a footnote
34 on multiple lines.
35 """,
36 """\
37 <document source="test data">
38 <footnote ids="id1" names="1">
39 <label>
41 <paragraph>
42 This is a footnote
43 on multiple lines.
44 """],
45 ["""\
46 .. [1] This is a footnote
47 on multiple lines with more space.
49 .. [2] This is a footnote
50 on multiple lines with less space.
51 """,
52 """\
53 <document source="test data">
54 <footnote ids="id1" names="1">
55 <label>
57 <paragraph>
58 This is a footnote
59 on multiple lines with more space.
60 <footnote ids="id2" names="2">
61 <label>
63 <paragraph>
64 This is a footnote
65 on multiple lines with less space.
66 """],
67 ["""\
68 .. [1]
69 This is a footnote on multiple lines
70 whose block starts on line 2.
71 """,
72 """\
73 <document source="test data">
74 <footnote ids="id1" names="1">
75 <label>
77 <paragraph>
78 This is a footnote on multiple lines
79 whose block starts on line 2.
80 """],
81 ["""\
82 .. [1]
84 That was an empty footnote.
85 """,
86 """\
87 <document source="test data">
88 <footnote ids="id1" names="1">
89 <label>
91 <paragraph>
92 That was an empty footnote.
93 """],
94 ["""\
95 .. [1]
96 No blank line.
97 """,
98 """\
99 <document source="test data">
100 <footnote ids="id1" names="1">
101 <label>
103 <system_message level="2" line="2" source="test data" type="WARNING">
104 <paragraph>
105 Explicit markup ends without a blank line; unexpected unindent.
106 <paragraph>
107 No blank line.
108 """],
111 totest['auto_numbered_footnotes'] = [
112 ["""\
113 [#]_ is the first auto-numbered footnote reference.
114 [#]_ is the second auto-numbered footnote reference.
116 .. [#] Auto-numbered footnote 1.
117 .. [#] Auto-numbered footnote 2.
118 .. [#] Auto-numbered footnote 3.
120 [#]_ is the third auto-numbered footnote reference.
121 """,
122 """\
123 <document source="test data">
124 <paragraph>
125 <footnote_reference auto="1" ids="id1">
126 is the first auto-numbered footnote reference.
127 <footnote_reference auto="1" ids="id2">
128 is the second auto-numbered footnote reference.
129 <footnote auto="1" ids="id3">
130 <paragraph>
131 Auto-numbered footnote 1.
132 <footnote auto="1" ids="id4">
133 <paragraph>
134 Auto-numbered footnote 2.
135 <footnote auto="1" ids="id5">
136 <paragraph>
137 Auto-numbered footnote 3.
138 <paragraph>
139 <footnote_reference auto="1" ids="id6">
140 is the third auto-numbered footnote reference.
141 """],
142 ["""\
143 [#third]_ is a reference to the third auto-numbered footnote.
145 .. [#first] First auto-numbered footnote.
146 .. [#second] Second auto-numbered footnote.
147 .. [#third] Third auto-numbered footnote.
149 [#second]_ is a reference to the second auto-numbered footnote.
150 [#first]_ is a reference to the first auto-numbered footnote.
151 [#third]_ is another reference to the third auto-numbered footnote.
153 Here are some internal cross-references to the targets generated by
154 the footnotes: first_, second_, third_.
155 """,
156 """\
157 <document source="test data">
158 <paragraph>
159 <footnote_reference auto="1" ids="id1" refname="third">
160 is a reference to the third auto-numbered footnote.
161 <footnote auto="1" ids="first" names="first">
162 <paragraph>
163 First auto-numbered footnote.
164 <footnote auto="1" ids="second" names="second">
165 <paragraph>
166 Second auto-numbered footnote.
167 <footnote auto="1" ids="third" names="third">
168 <paragraph>
169 Third auto-numbered footnote.
170 <paragraph>
171 <footnote_reference auto="1" ids="id2" refname="second">
172 is a reference to the second auto-numbered footnote.
173 <footnote_reference auto="1" ids="id3" refname="first">
174 is a reference to the first auto-numbered footnote.
175 <footnote_reference auto="1" ids="id4" refname="third">
176 is another reference to the third auto-numbered footnote.
177 <paragraph>
178 Here are some internal cross-references to the targets generated by
179 the footnotes: \n\
180 <reference name="first" refname="first">
181 first
182 , \n\
183 <reference name="second" refname="second">
184 second
185 , \n\
186 <reference name="third" refname="third">
187 third
189 """],
190 ["""\
191 Mixed anonymous and labelled auto-numbered footnotes:
193 [#four]_ should be 4, [#]_ should be 1,
194 [#]_ should be 3, [#]_ is one too many,
195 [#two]_ should be 2, and [#six]_ doesn't exist.
197 .. [#] Auto-numbered footnote 1.
198 .. [#two] Auto-numbered footnote 2.
199 .. [#] Auto-numbered footnote 3.
200 .. [#four] Auto-numbered footnote 4.
201 .. [#five] Auto-numbered footnote 5.
202 .. [#five] Auto-numbered footnote 5 again (duplicate).
203 """,
204 """\
205 <document source="test data">
206 <paragraph>
207 Mixed anonymous and labelled auto-numbered footnotes:
208 <paragraph>
209 <footnote_reference auto="1" ids="id1" refname="four">
210 should be 4, \n\
211 <footnote_reference auto="1" ids="id2">
212 should be 1,
213 <footnote_reference auto="1" ids="id3">
214 should be 3, \n\
215 <footnote_reference auto="1" ids="id4">
216 is one too many,
217 <footnote_reference auto="1" ids="id5" refname="two">
218 should be 2, and \n\
219 <footnote_reference auto="1" ids="id6" refname="six">
220 doesn't exist.
221 <footnote auto="1" ids="id7">
222 <paragraph>
223 Auto-numbered footnote 1.
224 <footnote auto="1" ids="two" names="two">
225 <paragraph>
226 Auto-numbered footnote 2.
227 <footnote auto="1" ids="id8">
228 <paragraph>
229 Auto-numbered footnote 3.
230 <footnote auto="1" ids="four" names="four">
231 <paragraph>
232 Auto-numbered footnote 4.
233 <footnote auto="1" dupnames="five" ids="five">
234 <paragraph>
235 Auto-numbered footnote 5.
236 <footnote auto="1" dupnames="five" ids="id9">
237 <system_message backrefs="id9" level="2" line="12" source="test data" type="WARNING">
238 <paragraph>
239 Duplicate explicit target name: "five".
240 <paragraph>
241 Auto-numbered footnote 5 again (duplicate).
242 """],
243 ["""\
244 Mixed manually-numbered, anonymous auto-numbered,
245 and labelled auto-numbered footnotes:
247 [#four]_ should be 4, [#]_ should be 2,
248 [1]_ is 1, [3]_ is 3,
249 [#]_ should be 6, [#]_ is one too many,
250 [#five]_ should be 5, and [#six]_ doesn't exist.
252 .. [1] Manually-numbered footnote 1.
253 .. [#] Auto-numbered footnote 2.
254 .. [#four] Auto-numbered footnote 4.
255 .. [3] Manually-numbered footnote 3
256 .. [#five] Auto-numbered footnote 5.
257 .. [#five] Auto-numbered footnote 5 again (duplicate).
258 .. [#] Auto-numbered footnote 6.
259 """,
260 """\
261 <document source="test data">
262 <paragraph>
263 Mixed manually-numbered, anonymous auto-numbered,
264 and labelled auto-numbered footnotes:
265 <paragraph>
266 <footnote_reference auto="1" ids="id1" refname="four">
267 should be 4, \n\
268 <footnote_reference auto="1" ids="id2">
269 should be 2,
270 <footnote_reference ids="id3" refname="1">
272 is 1, \n\
273 <footnote_reference ids="id4" refname="3">
275 is 3,
276 <footnote_reference auto="1" ids="id5">
277 should be 6, \n\
278 <footnote_reference auto="1" ids="id6">
279 is one too many,
280 <footnote_reference auto="1" ids="id7" refname="five">
281 should be 5, and \n\
282 <footnote_reference auto="1" ids="id8" refname="six">
283 doesn't exist.
284 <footnote ids="id9" names="1">
285 <label>
287 <paragraph>
288 Manually-numbered footnote 1.
289 <footnote auto="1" ids="id10">
290 <paragraph>
291 Auto-numbered footnote 2.
292 <footnote auto="1" ids="four" names="four">
293 <paragraph>
294 Auto-numbered footnote 4.
295 <footnote ids="id11" names="3">
296 <label>
298 <paragraph>
299 Manually-numbered footnote 3
300 <footnote auto="1" dupnames="five" ids="five">
301 <paragraph>
302 Auto-numbered footnote 5.
303 <footnote auto="1" dupnames="five" ids="id12">
304 <system_message backrefs="id12" level="2" line="14" source="test data" type="WARNING">
305 <paragraph>
306 Duplicate explicit target name: "five".
307 <paragraph>
308 Auto-numbered footnote 5 again (duplicate).
309 <footnote auto="1" ids="id13">
310 <paragraph>
311 Auto-numbered footnote 6.
312 """],
315 totest['auto_symbol_footnotes'] = [
316 ["""\
317 .. [*] This is an auto-symbol footnote.
318 """,
319 """\
320 <document source="test data">
321 <footnote auto="*" ids="id1">
322 <paragraph>
323 This is an auto-symbol footnote.
324 """],
328 if __name__ == '__main__':
329 import unittest
330 unittest.main(defaultTest='suite')