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