~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/test_rst/test_targets.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
 
3
 
"""
4
 
:Author: David Goodger
5
 
:Contact: goodger@users.sourceforge.net
6
 
:Revision: $Revision: 1.4 $
7
 
:Date: $Date: 2002/06/27 01:26:44 $
8
 
:Copyright: This module has been placed in the public domain.
9
 
 
10
 
Tests for states.py.
11
 
"""
12
 
 
13
 
from __init__ import DocutilsTestSupport
14
 
 
15
 
def suite():
16
 
    s = DocutilsTestSupport.ParserTestSuite()
17
 
    s.generateTests(totest)
18
 
    return s
19
 
 
20
 
totest = {}
21
 
 
22
 
totest['targets'] = [
23
 
["""\
24
 
.. _target:
25
 
 
26
 
(Internal hyperlink target.)
27
 
""",
28
 
"""\
29
 
<document>
30
 
    <target id="target" name="target">
31
 
    <paragraph>
32
 
        (Internal hyperlink target.)
33
 
"""],
34
 
["""\
35
 
External hyperlink targets:
36
 
 
37
 
.. _one-liner: http://structuredtext.sourceforge.net
38
 
 
39
 
.. _starts-on-this-line: http://
40
 
                         structuredtext.
41
 
                         sourceforge.net
42
 
 
43
 
.. _entirely-below:
44
 
   http://structuredtext.
45
 
   sourceforge.net
46
 
 
47
 
.. _not-indirect: uri\_
48
 
""",
49
 
"""\
50
 
<document>
51
 
    <paragraph>
52
 
        External hyperlink targets:
53
 
    <target id="one-liner" name="one-liner" refuri="http://structuredtext.sourceforge.net">
54
 
    <target id="starts-on-this-line" name="starts-on-this-line" refuri="http://structuredtext.sourceforge.net">
55
 
    <target id="entirely-below" name="entirely-below" refuri="http://structuredtext.sourceforge.net">
56
 
    <target id="not-indirect" name="not-indirect" refuri="uri_">
57
 
"""],
58
 
["""\
59
 
Indirect hyperlink targets:
60
 
 
61
 
.. _target1: reference_
62
 
 
63
 
.. _target2: `phrase-link reference`_
64
 
""",
65
 
"""\
66
 
<document>
67
 
    <paragraph>
68
 
        Indirect hyperlink targets:
69
 
    <target id="target1" name="target1" refname="reference">
70
 
    <target id="target2" name="target2" refname="phrase-link reference">
71
 
"""],
72
 
["""\
73
 
.. _target1: Not a proper hyperlink target
74
 
 
75
 
.. _target2: Although it ends with an underscore, this is not a phrase-link_
76
 
 
77
 
.. _target3: A multi-line verson of something
78
 
   ending with an underscore, but not a phrase-link_
79
 
""",
80
 
"""\
81
 
<document>
82
 
    <system_message level="2" type="WARNING">
83
 
        <paragraph>
84
 
            Hyperlink target at line 1 contains whitespace. Perhaps a footnote was intended?
85
 
        <literal_block>
86
 
            .. _target1: Not a proper hyperlink target
87
 
    <system_message level="2" type="WARNING">
88
 
        <paragraph>
89
 
            Hyperlink target at line 3 contains whitespace. Perhaps a footnote was intended?
90
 
        <literal_block>
91
 
            .. _target2: Although it ends with an underscore, this is not a phrase-link_
92
 
    <system_message level="2" type="WARNING">
93
 
        <paragraph>
94
 
            Hyperlink target at line 5 contains whitespace. Perhaps a footnote was intended?
95
 
        <literal_block>
96
 
            .. _target3: A multi-line verson of something
97
 
               ending with an underscore, but not a phrase-link_
98
 
"""],
99
 
["""\
100
 
.. __: Not a proper hyperlink target
101
 
 
102
 
__ Although it ends with an underscore, this is not a phrase-link_
103
 
 
104
 
__ A multi-line verson of something
105
 
   ending with an underscore, but not a phrase-link_
106
 
""",
107
 
"""\
108
 
<document>
109
 
    <system_message level="2" type="WARNING">
110
 
        <paragraph>
111
 
            Hyperlink target at line 1 contains whitespace. Perhaps a footnote was intended?
112
 
        <literal_block>
113
 
            .. __: Not a proper hyperlink target
114
 
    <system_message level="2" type="WARNING">
115
 
        <paragraph>
116
 
            Anonymous hyperlink target at line 3 contains whitespace. Perhaps a footnote was intended?
117
 
        <literal_block>
118
 
            __ Although it ends with an underscore, this is not a phrase-link_
119
 
    <system_message level="2" type="WARNING">
120
 
        <paragraph>
121
 
            Anonymous hyperlink target at line 5 contains whitespace. Perhaps a footnote was intended?
122
 
        <literal_block>
123
 
            __ A multi-line verson of something
124
 
            ending with an underscore, but not a phrase-link_
125
 
"""],
126
 
["""\
127
 
.. _a long target name:
128
 
 
129
 
.. _`a target name: including a colon (quoted)`:
130
 
 
131
 
.. _a target name\: including a colon (escaped):
132
 
""",
133
 
"""\
134
 
<document>
135
 
    <target id="a-long-target-name" name="a long target name">
136
 
    <target id="a-target-name-including-a-colon-quoted" name="a target name: including a colon (quoted)">
137
 
    <target id="a-target-name-including-a-colon-escaped" name="a target name: including a colon (escaped)">
138
 
"""],
139
 
["""\
140
 
.. _a very long target name,
141
 
   split across lines:
142
 
.. _`and another,
143
 
   with backquotes`:
144
 
""",
145
 
"""\
146
 
<document>
147
 
    <target id="a-very-long-target-name-split-across-lines" name="a very long target name, split across lines">
148
 
    <target id="and-another-with-backquotes" name="and another, with backquotes">
149
 
"""],
150
 
["""\
151
 
External hyperlink:
152
 
 
153
 
.. _target: http://www.python.org/
154
 
""",
155
 
"""\
156
 
<document>
157
 
    <paragraph>
158
 
        External hyperlink:
159
 
    <target id="target" name="target" refuri="http://www.python.org/">
160
 
"""],
161
 
["""\
162
 
Duplicate external targets (different URIs):
163
 
 
164
 
.. _target: first
165
 
 
166
 
.. _target: second
167
 
""",
168
 
"""\
169
 
<document>
170
 
    <paragraph>
171
 
        Duplicate external targets (different URIs):
172
 
    <target dupname="target" id="target" refuri="first">
173
 
    <system_message backrefs="id1" level="2" type="WARNING">
174
 
        <paragraph>
175
 
            Duplicate explicit target name: "target".
176
 
    <target dupname="target" id="id1" refuri="second">
177
 
"""],
178
 
["""\
179
 
Duplicate external targets (same URIs):
180
 
 
181
 
.. _target: first
182
 
 
183
 
.. _target: first
184
 
""",
185
 
"""\
186
 
<document>
187
 
    <paragraph>
188
 
        Duplicate external targets (same URIs):
189
 
    <target id="target" name="target" refuri="first">
190
 
    <system_message backrefs="id1" level="1" type="INFO">
191
 
        <paragraph>
192
 
            Duplicate explicit target name: "target".
193
 
    <target dupname="target" id="id1" refuri="first">
194
 
"""],
195
 
["""\
196
 
Duplicate implicit targets.
197
 
 
198
 
Title
199
 
=====
200
 
 
201
 
Paragraph.
202
 
 
203
 
Title
204
 
=====
205
 
 
206
 
Paragraph.
207
 
""",
208
 
"""\
209
 
<document>
210
 
    <paragraph>
211
 
        Duplicate implicit targets.
212
 
    <section dupname="title" id="title">
213
 
        <title>
214
 
            Title
215
 
        <paragraph>
216
 
            Paragraph.
217
 
    <section dupname="title" id="id1">
218
 
        <title>
219
 
            Title
220
 
        <system_message backrefs="id1" level="1" type="INFO">
221
 
            <paragraph>
222
 
                Duplicate implicit target name: "title".
223
 
        <paragraph>
224
 
            Paragraph.
225
 
"""],
226
 
["""\
227
 
Duplicate implicit/explicit targets.
228
 
 
229
 
Title
230
 
=====
231
 
 
232
 
.. _title:
233
 
 
234
 
Paragraph.
235
 
""",
236
 
"""\
237
 
<document>
238
 
    <paragraph>
239
 
        Duplicate implicit/explicit targets.
240
 
    <section dupname="title" id="title">
241
 
        <title>
242
 
            Title
243
 
        <system_message backrefs="id1" level="1" type="INFO">
244
 
            <paragraph>
245
 
                Duplicate implicit target name: "title".
246
 
        <target id="id1" name="title">
247
 
        <paragraph>
248
 
            Paragraph.
249
 
"""],
250
 
["""\
251
 
Duplicate explicit targets.
252
 
 
253
 
.. _title:
254
 
 
255
 
First.
256
 
 
257
 
.. _title:
258
 
 
259
 
Second.
260
 
 
261
 
.. _title:
262
 
 
263
 
Third.
264
 
""",
265
 
"""\
266
 
<document>
267
 
    <paragraph>
268
 
        Duplicate explicit targets.
269
 
    <target dupname="title" id="title">
270
 
    <paragraph>
271
 
        First.
272
 
    <system_message backrefs="id1" level="2" type="WARNING">
273
 
        <paragraph>
274
 
            Duplicate explicit target name: "title".
275
 
    <target dupname="title" id="id1">
276
 
    <paragraph>
277
 
        Second.
278
 
    <system_message backrefs="id2" level="2" type="WARNING">
279
 
        <paragraph>
280
 
            Duplicate explicit target name: "title".
281
 
    <target dupname="title" id="id2">
282
 
    <paragraph>
283
 
        Third.
284
 
"""],
285
 
["""\
286
 
Duplicate targets:
287
 
 
288
 
Target
289
 
======
290
 
 
291
 
Implicit section header target.
292
 
 
293
 
.. [target] Citation target.
294
 
 
295
 
.. [#target] Autonumber-labeled footnote target.
296
 
 
297
 
.. _target:
298
 
 
299
 
Explicit internal target.
300
 
 
301
 
.. _target: Explicit_external_target
302
 
""",
303
 
"""\
304
 
<document>
305
 
    <paragraph>
306
 
        Duplicate targets:
307
 
    <section dupname="target" id="target">
308
 
        <title>
309
 
            Target
310
 
        <paragraph>
311
 
            Implicit section header target.
312
 
        <citation dupname="target" id="id1">
313
 
            <label>
314
 
                target
315
 
            <system_message backrefs="id1" level="1" type="INFO">
316
 
                <paragraph>
317
 
                    Duplicate implicit target name: "target".
318
 
            <paragraph>
319
 
                Citation target.
320
 
        <footnote auto="1" dupname="target" id="id2">
321
 
            <system_message backrefs="id2" level="2" type="WARNING">
322
 
                <paragraph>
323
 
                    Duplicate explicit target name: "target".
324
 
            <paragraph>
325
 
                Autonumber-labeled footnote target.
326
 
        <system_message backrefs="id3" level="2" type="WARNING">
327
 
            <paragraph>
328
 
                Duplicate explicit target name: "target".
329
 
        <target dupname="target" id="id3">
330
 
        <paragraph>
331
 
            Explicit internal target.
332
 
        <system_message backrefs="id4" level="2" type="WARNING">
333
 
            <paragraph>
334
 
                Duplicate explicit target name: "target".
335
 
        <target dupname="target" id="id4" refuri="Explicit_external_target">
336
 
"""],
337
 
]
338
 
 
339
 
totest['anonymous_targets'] = [
340
 
["""\
341
 
Anonymous external hyperlink target:
342
 
 
343
 
.. __: http://w3c.org/
344
 
""",
345
 
"""\
346
 
<document>
347
 
    <paragraph>
348
 
        Anonymous external hyperlink target:
349
 
    <target anonymous="1" id="id1" refuri="http://w3c.org/">
350
 
"""],
351
 
["""\
352
 
Anonymous external hyperlink target:
353
 
 
354
 
__ http://w3c.org/
355
 
""",
356
 
"""\
357
 
<document>
358
 
    <paragraph>
359
 
        Anonymous external hyperlink target:
360
 
    <target anonymous="1" id="id1" refuri="http://w3c.org/">
361
 
"""],
362
 
["""\
363
 
Anonymous indirect hyperlink target:
364
 
 
365
 
.. __: reference_
366
 
""",
367
 
"""\
368
 
<document>
369
 
    <paragraph>
370
 
        Anonymous indirect hyperlink target:
371
 
    <target anonymous="1" id="id1" refname="reference">
372
 
"""],
373
 
["""\
374
 
Anonymous indirect hyperlink targets:
375
 
 
376
 
__ reference_
377
 
__ `a very long
378
 
   reference`_
379
 
""",
380
 
"""\
381
 
<document>
382
 
    <paragraph>
383
 
        Anonymous indirect hyperlink targets:
384
 
    <target anonymous="1" id="id1" refname="reference">
385
 
    <target anonymous="1" id="id2" refname="a very long reference">
386
 
"""],
387
 
["""\
388
 
Mixed anonymous & named indirect hyperlink targets:
389
 
 
390
 
__ reference_
391
 
.. __: reference_
392
 
__ reference_
393
 
.. _target1: reference_
394
 
no blank line
395
 
 
396
 
.. _target2: reference_
397
 
__ reference_
398
 
.. __: reference_
399
 
__ reference_
400
 
no blank line
401
 
""",
402
 
"""\
403
 
<document>
404
 
    <paragraph>
405
 
        Mixed anonymous & named indirect hyperlink targets:
406
 
    <target anonymous="1" id="id1" refname="reference">
407
 
    <target anonymous="1" id="id2" refname="reference">
408
 
    <target anonymous="1" id="id3" refname="reference">
409
 
    <target id="target1" name="target1" refname="reference">
410
 
    <system_message level="2" type="WARNING">
411
 
        <paragraph>
412
 
            Explicit markup ends without a blank line; unexpected unindent at line 7.
413
 
    <paragraph>
414
 
        no blank line
415
 
    <target id="target2" name="target2" refname="reference">
416
 
    <target anonymous="1" id="id4" refname="reference">
417
 
    <target anonymous="1" id="id5" refname="reference">
418
 
    <target anonymous="1" id="id6" refname="reference">
419
 
    <system_message level="2" type="WARNING">
420
 
        <paragraph>
421
 
            Explicit markup ends without a blank line; unexpected unindent at line 13.
422
 
    <paragraph>
423
 
        no blank line
424
 
"""],
425
 
]
426
 
 
427
 
if __name__ == '__main__':
428
 
    import unittest
429
 
    unittest.main(defaultTest='suite')