Fix [ 3607029 ] traceback with embedded alias pointing to missing target.
[docutils.git] / docutils / test / test_transforms / test_hyperlinks.py
blob6f4081ad9c2f366249ef40bcea7afd4b01123657
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 docutils.transforms.references.Hyperlinks.
9 """
11 from __init__ import DocutilsTestSupport
12 from docutils.transforms.references import PropagateTargets, \
13 AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, \
14 InternalTargets, DanglingReferences
16 from docutils.parsers.rst import Parser
19 def suite():
20 parser = Parser()
21 s = DocutilsTestSupport.TransformTestSuite(parser)
22 s.generateTests(totest)
23 return s
25 totest = {}
27 # Exhaustive listing of hyperlink variations: every combination of
28 # target/reference, direct/indirect, internal/external, and named/anonymous,
29 # plus embedded URIs.
30 totest['exhaustive_hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
31 IndirectHyperlinks,
32 ExternalTargets, InternalTargets,
33 DanglingReferences), [
34 ["""\
35 direct_ external
37 .. _direct: http://direct
38 """,
39 """\
40 <document source="test data">
41 <paragraph>
42 <reference name="direct" refuri="http://direct">
43 direct
44 external
45 <target ids="direct" names="direct" refuri="http://direct">
46 """],
47 ["""\
48 indirect_ external
50 .. _indirect: xtarget_
51 .. _xtarget: http://indirect
52 """,
53 """\
54 <document source="test data">
55 <paragraph>
56 <reference name="indirect" refuri="http://indirect">
57 indirect
58 external
59 <target ids="indirect" names="indirect" refuri="http://indirect">
60 <target ids="xtarget" names="xtarget" refuri="http://indirect">
61 """],
62 ["""\
63 .. _direct:
65 direct_ internal
66 """,
67 """\
68 <document source="test data">
69 <target refid="direct">
70 <paragraph ids="direct" names="direct">
71 <reference name="direct" refid="direct">
72 direct
73 internal
74 """],
75 ["""\
76 .. _ztarget:
78 indirect_ internal
80 .. _indirect2: ztarget_
81 .. _indirect: indirect2_
82 """,
83 """\
84 <document source="test data">
85 <target refid="ztarget">
86 <paragraph ids="ztarget" names="ztarget">
87 <reference name="indirect" refid="ztarget">
88 indirect
89 internal
90 <target ids="indirect2" names="indirect2" refid="ztarget">
91 <target ids="indirect" names="indirect" refid="ztarget">
92 """],
93 ["""\
94 Implicit
95 --------
97 indirect_ internal
99 .. _indirect: implicit_
100 """,
101 """\
102 <document source="test data">
103 <section ids="implicit" names="implicit">
104 <title>
105 Implicit
106 <paragraph>
107 <reference name="indirect" refid="implicit">
108 indirect
109 internal
110 <target ids="indirect" names="indirect" refid="implicit">
111 """],
112 ["""\
113 Implicit
114 --------
116 `multiply-indirect`_ internal
118 .. _multiply-indirect: indirect_
119 .. _indirect: implicit_
120 """,
121 """\
122 <document source="test data">
123 <section ids="implicit" names="implicit">
124 <title>
125 Implicit
126 <paragraph>
127 <reference name="multiply-indirect" refid="implicit">
128 multiply-indirect
129 internal
130 <target ids="multiply-indirect" names="multiply-indirect" refid="implicit">
131 <target ids="indirect" names="indirect" refid="implicit">
132 """],
133 ["""\
134 circular_ indirect reference
136 .. _circular: indirect_
137 .. _indirect: circular_
138 """,
139 """\
140 <document source="test data">
141 <paragraph>
142 <problematic ids="id2" refid="id1">
143 circular_
144 indirect reference
145 <target ids="circular" names="circular" refid="circular">
146 <problematic ids="id3 indirect" names="indirect" refid="id1">
147 .. _indirect: circular_
148 <system_message backrefs="id2 id3" ids="id1" level="3" line="3" source="test data" type="ERROR">
149 <paragraph>
150 Indirect hyperlink target "circular" (id="circular") refers to target "indirect", forming a circular reference.
151 """],
152 ["""\
153 Implicit
154 --------
156 Duplicate implicit targets.
158 Implicit
159 --------
161 indirect_ internal
163 .. _indirect: implicit_
165 Direct internal reference: Implicit_
166 """,
167 """\
168 <document source="test data">
169 <section dupnames="implicit" ids="implicit">
170 <title>
171 Implicit
172 <paragraph>
173 Duplicate implicit targets.
174 <section dupnames="implicit" ids="id1">
175 <title>
176 Implicit
177 <system_message backrefs="id1" level="1" line="7" source="test data" type="INFO">
178 <paragraph>
179 Duplicate implicit target name: "implicit".
180 <paragraph>
181 <problematic ids="id3" refid="id2">
182 indirect_
183 internal
184 <target ids="indirect" names="indirect" refname="implicit">
185 <paragraph>
186 Direct internal reference:
187 <problematic ids="id5" refid="id4">
188 Implicit_
189 <system_message backrefs="id3" ids="id2" level="3" line="11" source="test data" type="ERROR">
190 <paragraph>
191 Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which is a duplicate, and cannot be used as a unique reference.
192 <system_message backrefs="id5" ids="id4" level="3" line="13" source="test data" type="ERROR">
193 <paragraph>
194 Duplicate target name, cannot be used as a unique reference: "implicit".
195 """],
196 ["""\
197 `direct external`__
199 __ http://direct
200 """,
201 """\
202 <document source="test data">
203 <paragraph>
204 <reference anonymous="1" name="direct external" refuri="http://direct">
205 direct external
206 <target anonymous="1" ids="id1" refuri="http://direct">
207 """],
208 ["""\
209 `indirect external`__
211 __ xtarget_
212 .. _xtarget: http://indirect
213 """,
214 """\
215 <document source="test data">
216 <paragraph>
217 <reference anonymous="1" name="indirect external" refuri="http://indirect">
218 indirect external
219 <target anonymous="1" ids="id1" refuri="http://indirect">
220 <target ids="xtarget" names="xtarget" refuri="http://indirect">
221 """],
222 ["""\
225 `direct internal`__
226 """,
227 """\
228 <document source="test data">
229 <target anonymous="1" refid="id1">
230 <paragraph ids="id1">
231 <reference anonymous="1" name="direct internal" refid="id1">
232 direct internal
233 """],
234 ["""\
235 .. _ztarget:
237 `indirect internal`__
239 __ ztarget_
240 """,
241 """\
242 <document source="test data">
243 <target refid="ztarget">
244 <paragraph ids="ztarget" names="ztarget">
245 <reference anonymous="1" name="indirect internal" refid="ztarget">
246 indirect internal
247 <target anonymous="1" ids="id1" refid="ztarget">
248 """],
249 ["""\
250 .. _ztarget:
252 First
254 .. _ztarget:
256 Second
258 `indirect internal`__
260 __ ztarget_
261 """,
262 """\
263 <document source="test data">
264 <target dupnames="ztarget" refid="ztarget">
265 <paragraph ids="ztarget">
266 First
267 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
268 <paragraph>
269 Duplicate explicit target name: "ztarget".
270 <target dupnames="ztarget" refid="id1">
271 <paragraph ids="id1">
272 Second
273 <paragraph>
274 <problematic ids="id4" refid="id3">
275 `indirect internal`__
276 <target anonymous="1" ids="id2" refname="ztarget">
277 <system_message backrefs="id4" ids="id3" level="3" line="11" source="test data" type="ERROR">
278 <paragraph>
279 Indirect hyperlink target (id="id2") refers to target "ztarget", which is a duplicate, and cannot be used as a unique reference.
280 """],
281 ["""\
282 The next anonymous hyperlink reference is parsed (and discarded) at
283 some point, but nonetheless anonymous hyperlink references and targets
284 match in this snippet.
286 .. |invalid| replace:: anonymous__
288 hyperlink__
290 __ URL
291 """,
292 """\
293 <document source="test data">
294 <paragraph>
295 The next anonymous hyperlink reference is parsed (and discarded) at
296 some point, but nonetheless anonymous hyperlink references and targets
297 match in this snippet.
298 <system_message level="3" line="5" source="test data" type="ERROR">
299 <paragraph>
300 Substitution definition contains illegal element:
301 <literal_block xml:space="preserve">
302 <reference anonymous="1" name="anonymous">
303 anonymous
304 <literal_block xml:space="preserve">
305 .. |invalid| replace:: anonymous__
306 <paragraph>
307 <reference anonymous="1" name="hyperlink" refuri="URL">
308 hyperlink
309 <target anonymous="1" ids="id1" refuri="URL">
310 """],
311 ["""\
312 An `embedded uri <http://direct>`_.
314 Another reference to the same `embedded URI`_.
315 """,
316 """\
317 <document source="test data">
318 <paragraph>
319 An \n\
320 <reference name="embedded uri" refuri="http://direct">
321 embedded uri
322 <target ids="embedded-uri" names="embedded\ uri" refuri="http://direct">
324 <paragraph>
325 Another reference to the same \n\
326 <reference name="embedded URI" refuri="http://direct">
327 embedded URI
329 """],
330 ["""\
331 An `anonymous embedded uri <http://direct>`__.
332 """,
333 """\
334 <document source="test data">
335 <paragraph>
336 An \n\
337 <reference name="anonymous embedded uri" refuri="http://direct">
338 anonymous embedded uri
340 """],
341 ["""\
342 An `embedded alias <alias_>`_.
344 Another reference to the same `embedded alias`_.
346 .. _alias: ham.py
347 """,
348 """\
349 <document source="test data">
350 <paragraph>
351 An \n\
352 <reference name="embedded alias" refuri="ham.py">
353 embedded alias
354 <target names="embedded\ alias" refuri="ham.py">
356 <paragraph>
357 Another reference to the same \n\
358 <reference name="embedded alias" refuri="ham.py">
359 embedded alias
361 <target ids="alias" names="alias" refuri="ham.py">
362 """],
363 ["""\
364 An `anonymous embedded alias <redirect_>`__.
366 .. _redirect: spam.py
367 """,
368 """\
369 <document source="test data">
370 <paragraph>
371 An \n\
372 <reference name="anonymous embedded alias" refuri="spam.py">
373 anonymous embedded alias
375 <target ids="redirect" names="redirect" refuri="spam.py">
376 """],
377 # TODO: suppress the INFO message?
378 ["""\
379 An `embedded alias <alias_>`_ with unknown reference.
380 """,
381 """\
382 <document source="test data">
383 <paragraph>
384 An \n\
385 <problematic ids="id3" refid="id2">
386 `embedded alias <alias_>`_
387 <target names="embedded\ alias" refname="alias">
388 with unknown reference.
389 <system_message ids="id1" level="3" line="1" source="test data" type="ERROR">
390 <paragraph>
391 Indirect hyperlink target "embedded alias" refers to target "alias", which does not exist.
392 <system_message backrefs="id3" ids="id2" level="3" line="1" source="test data" type="ERROR">
393 <paragraph>
394 Unknown target name: "alias".
395 <system_message level="1" line="1" source="test data" type="INFO">
396 <paragraph>
397 Hyperlink target "embedded alias" is not referenced.\
398 """],
399 ["""\
400 .. _target:
402 .. [1] Footnote; target_
403 """,
404 """\
405 <document source="test data">
406 <target ids="target" names="target">
407 <footnote ids="id1" names="1">
408 <label>
410 <paragraph>
411 Footnote; \n\
412 <reference name="target" refid="target">
413 target
414 """],
415 ["""\
416 .. _target:
418 .. [cit] Citation; target_
419 """,
420 """\
421 <document source="test data">
422 <target ids="target" names="target">
423 <citation ids="cit" names="cit">
424 <label>
426 <paragraph>
427 Citation; \n\
428 <reference name="target" refid="target">
429 target
430 """],
433 totest['hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
434 IndirectHyperlinks, ExternalTargets,
435 InternalTargets, DanglingReferences), [
436 ["""\
437 .. _internal hyperlink:
439 This paragraph referenced.
441 By this `internal hyperlink`_ reference.
442 """,
443 """\
444 <document source="test data">
445 <target refid="internal-hyperlink">
446 <paragraph ids="internal-hyperlink" names="internal\ hyperlink">
447 This paragraph referenced.
448 <paragraph>
449 By this \n\
450 <reference name="internal hyperlink" refid="internal-hyperlink">
451 internal hyperlink
452 reference.
453 """],
454 ["""\
455 .. _chained:
456 .. _internal hyperlink:
458 This paragraph referenced.
460 By this `internal hyperlink`_ reference
461 as well as by this chained_ reference.
463 The results of the transform are not visible at the XML level.
464 """,
465 """\
466 <document source="test data">
467 <target refid="chained">
468 <target refid="internal-hyperlink">
469 <paragraph ids="internal-hyperlink chained" names="internal\ hyperlink chained">
470 This paragraph referenced.
471 <paragraph>
472 By this \n\
473 <reference name="internal hyperlink" refid="internal-hyperlink">
474 internal hyperlink
475 reference
476 as well as by this \n\
477 <reference name="chained" refid="chained">
478 chained
479 reference.
480 <paragraph>
481 The results of the transform are not visible at the XML level.
482 """],
483 ["""\
484 .. _chained:
485 __ http://anonymous
487 Anonymous__ and chained_ both refer to the same URI.
488 """,
489 """\
490 <document source="test data">
491 <target refid="chained">
492 <target anonymous="1" ids="id1 chained" names="chained" refuri="http://anonymous">
493 <paragraph>
494 <reference anonymous="1" name="Anonymous" refuri="http://anonymous">
495 Anonymous
496 and \n\
497 <reference name="chained" refuri="http://anonymous">
498 chained
499 both refer to the same URI.
500 """],
501 ["""\
502 .. _a:
503 .. _b:
506 """,
507 """\
508 <document source="test data">
509 <target refid="a">
510 <target refid="b">
511 <paragraph ids="b a" names="b a">
513 <system_message level="1" line="1" source="test data" type="INFO">
514 <paragraph>
515 Hyperlink target "a" is not referenced.
516 <system_message level="1" line="2" source="test data" type="INFO">
517 <paragraph>
518 Hyperlink target "b" is not referenced.
519 """],
520 ["""\
521 .. _a:
522 .. _b:
525 """,
526 """\
527 <document source="test data">
528 <target refid="a">
529 <target refid="b">
530 <paragraph ids="b a" names="b a">
531 <reference name="a" refid="a">
533 <system_message level="1" line="2" source="test data" type="INFO">
534 <paragraph>
535 Hyperlink target "b" is not referenced.
536 """],
537 ["""\
538 .. _a:
539 .. _b:
542 """,
543 """\
544 <document source="test data">
545 <target refid="a">
546 <target refid="b">
547 <paragraph ids="b a" names="b a">
548 <reference name="b" refid="b">
550 <system_message level="1" line="1" source="test data" type="INFO">
551 <paragraph>
552 Hyperlink target "a" is not referenced.
553 """],
554 ["""\
555 .. _a:
556 .. _b:
558 a_\ b_
559 """,
560 """\
561 <document source="test data">
562 <target refid="a">
563 <target refid="b">
564 <paragraph ids="b a" names="b a">
565 <reference name="a" refid="a">
567 <reference name="b" refid="b">
569 """],
570 ["""\
571 .. _external hyperlink: http://uri
573 `External hyperlink`_ reference.
574 """,
575 """\
576 <document source="test data">
577 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
578 <paragraph>
579 <reference name="External hyperlink" refuri="http://uri">
580 External hyperlink
581 reference.
582 """],
583 ["""\
584 .. _external hyperlink: http://uri
585 .. _indirect target: `external hyperlink`_
586 """,
587 """\
588 <document source="test data">
589 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
590 <target ids="indirect-target" names="indirect\ target" refuri="http://uri">
591 <system_message level="1" line="2" source="test data" type="INFO">
592 <paragraph>
593 Hyperlink target "indirect target" is not referenced.
594 """],
595 ["""\
596 .. _chained:
597 .. _external hyperlink: http://uri
599 `External hyperlink`_ reference
600 and a chained_ reference too.
601 """,
602 """\
603 <document source="test data">
604 <target refid="chained">
605 <target ids="external-hyperlink chained" names="external\ hyperlink chained" refuri="http://uri">
606 <paragraph>
607 <reference name="External hyperlink" refuri="http://uri">
608 External hyperlink
609 reference
610 and a \n\
611 <reference name="chained" refuri="http://uri">
612 chained
613 reference too.
614 """],
615 ["""\
616 .. _external hyperlink: http://uri
617 .. _indirect hyperlink: `external hyperlink`_
619 `Indirect hyperlink`_ reference.
620 """,
621 """\
622 <document source="test data">
623 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
624 <target ids="indirect-hyperlink" names="indirect\ hyperlink" refuri="http://uri">
625 <paragraph>
626 <reference name="Indirect hyperlink" refuri="http://uri">
627 Indirect hyperlink
628 reference.
629 """],
630 ["""\
631 .. _external hyperlink: http://uri
632 .. _chained:
633 .. _indirect hyperlink: `external hyperlink`_
635 Chained_ `indirect hyperlink`_ reference.
636 """,
637 """\
638 <document source="test data">
639 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
640 <target refuri="http://uri">
641 <target ids="indirect-hyperlink chained" names="indirect\ hyperlink chained" refuri="http://uri">
642 <paragraph>
643 <reference name="Chained" refuri="http://uri">
644 Chained
646 <reference name="indirect hyperlink" refuri="http://uri">
647 indirect hyperlink
648 reference.
649 """],
650 ["""\
651 .. __: http://full
653 __ http://simplified
654 .. _external: http://indirect.external
655 __ external_
658 `Full syntax anonymous external hyperlink reference`__,
659 `chained anonymous external reference`__,
660 `simplified syntax anonymous external hyperlink reference`__,
661 `indirect anonymous hyperlink reference`__,
662 `internal anonymous hyperlink reference`__.
663 """,
664 """\
665 <document source="test data">
666 <target anonymous="1" ids="id1" refuri="http://full">
667 <target anonymous="1" refid="id2">
668 <target anonymous="1" ids="id3 id2" refuri="http://simplified">
669 <target ids="external" names="external" refuri="http://indirect.external">
670 <target anonymous="1" ids="id4" refuri="http://indirect.external">
671 <target anonymous="1" refid="id5">
672 <paragraph ids="id5">
673 <reference anonymous="1" name="Full syntax anonymous external hyperlink reference" refuri="http://full">
674 Full syntax anonymous external hyperlink reference
676 <reference anonymous="1" name="chained anonymous external reference" refuri="http://simplified">
677 chained anonymous external reference
679 <reference anonymous="1" name="simplified syntax anonymous external hyperlink reference" refuri="http://simplified">
680 simplified syntax anonymous external hyperlink reference
682 <reference anonymous="1" name="indirect anonymous hyperlink reference" refuri="http://indirect.external">
683 indirect anonymous hyperlink reference
685 <reference anonymous="1" name="internal anonymous hyperlink reference" refid="id5">
686 internal anonymous hyperlink reference
688 """],
689 ["""\
690 Duplicate external target_'s (different URIs):
692 .. _target: first
694 .. _target: second
695 """,
696 """\
697 <document source="test data">
698 <paragraph>
699 Duplicate external \n\
700 <problematic ids="id3" refid="id2">
701 target_
702 's (different URIs):
703 <target dupnames="target" ids="target" refuri="first">
704 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
705 <paragraph>
706 Duplicate explicit target name: "target".
707 <target dupnames="target" ids="id1" refuri="second">
708 <system_message backrefs="id3" ids="id2" level="3" line="1" source="test data" type="ERROR">
709 <paragraph>
710 Duplicate target name, cannot be used as a unique reference: "target".
711 """],
712 ["""\
713 Duplicate external targets (different URIs) without reference:
715 .. _target: first
717 .. _target: second
718 """,
719 """\
720 <document source="test data">
721 <paragraph>
722 Duplicate external targets (different URIs) without reference:
723 <target dupnames="target" ids="target" refuri="first">
724 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
725 <paragraph>
726 Duplicate explicit target name: "target".
727 <target dupnames="target" ids="id1" refuri="second">
728 """],
729 ["""\
730 Several__ anonymous__ hyperlinks__, but not enough targets.
732 __ http://example.org
733 """,
734 """\
735 <document source="test data">
736 <paragraph>
737 <problematic ids="id3" refid="id2">
738 Several__
740 <problematic ids="id4" refid="id2">
741 anonymous__
743 <problematic ids="id5" refid="id2">
744 hyperlinks__
745 , but not enough targets.
746 <target anonymous="1" ids="id1" refuri="http://example.org">
747 <system_message backrefs="id3 id4 id5" ids="id2" level="3" source="test data" type="ERROR">
748 <paragraph>
749 Anonymous hyperlink mismatch: 3 references but 1 targets.
750 See "backrefs" attribute for IDs.
751 """],
752 ["""\
753 .. _external: http://uri
754 .. _indirect: external_
755 .. _internal:
757 .. image:: picture.png
758 :target: external_
760 .. image:: picture.png
761 :target: indirect_
763 .. image:: picture.png
764 :target: internal_
765 """,
766 """\
767 <document source="test data">
768 <target ids="external" names="external" refuri="http://uri">
769 <target ids="indirect" names="indirect" refuri="http://uri">
770 <target refid="internal">
771 <reference ids="internal" name="external" names="internal" refuri="http://uri">
772 <image uri="picture.png">
773 <reference name="indirect" refuri="http://uri">
774 <image uri="picture.png">
775 <reference name="internal" refid="internal">
776 <image uri="picture.png">
777 """],
778 ["""\
779 .. contents:: Table of Contents
780 .. _indirect reference to the table of contents: `table of contents`_
782 Section
783 =======
785 Testing an `indirect reference to the table of contents`_.
786 """,
787 """\
788 <document source="test data">
789 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
790 <title>
791 Table of Contents
792 <bullet_list>
793 <list_item>
794 <paragraph>
795 <reference ids="id1" refid="section">
796 Section
797 <target ids="indirect-reference-to-the-table-of-contents" names="indirect\ reference\ to\ the\ table\ of\ contents" refid="table-of-contents">
798 <section ids="section" names="section">
799 <title refid="id1">
800 Section
801 <paragraph>
802 Testing an
803 <reference name="indirect reference to the table of contents" refid="table-of-contents">
804 indirect reference to the table of contents
806 """],
807 ["""\
808 .. _explicit target:
810 Title
811 -----
813 Let's reference it (`explicit target`_) to avoid an irrelevant error.
814 """,
815 """\
816 <document source="test data">
817 <target refid="explicit-target">
818 <section ids="title explicit-target" names="title explicit\ target">
819 <title>
820 Title
821 <paragraph>
822 Let's reference it (
823 <reference name="explicit target" refid="explicit-target">
824 explicit target
825 ) to avoid an irrelevant error.
826 """],
827 ["""\
828 target1_ should refer to target2_, not the Title.
830 .. _target1:
831 .. _target2: URI
833 Title
834 =====
835 """,
836 """\
837 <document source="test data">
838 <paragraph>
839 <reference name="target1" refuri="URI">
840 target1
841 should refer to \n\
842 <reference name="target2" refuri="URI">
843 target2
844 , not the Title.
845 <target refid="target1">
846 <target ids="target2 target1" names="target2 target1" refuri="URI">
847 <section ids="title" names="title">
848 <title>
849 Title
850 """],
851 ["""\
852 Unknown reference_.
853 """,
854 """\
855 <document source="test data">
856 <paragraph>
857 Unknown \n\
858 <problematic ids="id2" refid="id1">
859 reference_
861 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
862 <paragraph>
863 Unknown target name: "reference".
864 """],
865 ["""\
866 Duplicate manual footnote labels, with reference ([1]_):
868 .. [1] Footnote.
870 .. [1] Footnote.
871 """,
872 """\
873 <document source="test data">
874 <paragraph>
875 Duplicate manual footnote labels, with reference (
876 <problematic ids="id5 id1" refid="id4">
877 [1]_
879 <footnote dupnames="1" ids="id2">
880 <label>
882 <paragraph>
883 Footnote.
884 <footnote dupnames="1" ids="id3">
885 <label>
887 <system_message backrefs="id3" level="2" line="5" source="test data" type="WARNING">
888 <paragraph>
889 Duplicate explicit target name: "1".
890 <paragraph>
891 Footnote.
892 <system_message backrefs="id5" ids="id4" level="3" line="1" source="test data" type="ERROR">
893 <paragraph>
894 Duplicate target name, cannot be used as a unique reference: "1".
895 """],
899 if __name__ == '__main__':
900 import unittest
901 unittest.main(defaultTest='suite')