1 # -*- coding: utf-8 -*-
5 # Author: David Goodger <goodger@python.org>
6 # Copyright: This module has been placed in the public domain.
8 """Tests for states.py."""
10 from __init__
import DocutilsTestSupport
13 s
= DocutilsTestSupport
.ParserTestSuite()
14 s
.generateTests(totest
)
19 totest
['section_headers'] = [
27 <document source="test data">
28 <section ids="title" names="title">
37 Paragraph (no blank line).
40 <document source="test data">
41 <section ids="title" names="title">
45 Paragraph (no blank line).
56 <document source="test data">
59 <section ids="title" names="title">
66 Test unexpected section titles.
78 <document source="test data">
80 Test unexpected section titles.
82 <system_message level="4" line="4" source="test data" type="SEVERE">
84 Unexpected section title.
85 <literal_block xml:space="preserve">
90 <system_message level="4" line="7" source="test data" type="SEVERE">
92 Unexpected section title or transition.
93 <literal_block xml:space="preserve">
95 <system_message level="4" line="9" source="test data" type="SEVERE">
97 Unexpected section title.
98 <literal_block xml:space="preserve">
108 Test short underline.
111 <document source="test data">
112 <section ids="title" names="title">
115 <system_message level="2" line="2" source="test data" type="WARNING">
117 Title underline too short.
118 <literal_block xml:space="preserve">
122 Test short underline.
125 à with combining varia
126 ======================
128 Do not count combining chars in title column width.
131 <document source="test data">
132 <section ids="a-with-combining-varia" names="a\u0300\ with\ combining\ varia">
134 à with combining varia
136 Do not count combining chars in title column width.
146 <document source="test data">
147 <section ids="title" names="title">
158 Test overline title with inset.
161 <document source="test data">
162 <section ids="title" names="title">
166 Test overline title with inset.
169 ========================
170 Test Missing Underline
173 <document source="test data">
174 <system_message level="4" line="1" source="test data" type="SEVERE">
176 Incomplete section title.
177 <literal_block xml:space="preserve">
178 ========================
179 Test Missing Underline
182 ========================
183 Test Missing Underline
187 <document source="test data">
188 <system_message level="4" line="1" source="test data" type="SEVERE">
190 Missing matching underline for section title overline.
191 <literal_block xml:space="preserve">
192 ========================
193 Test Missing Underline
199 Test missing underline, with paragraph.
202 <document source="test data">
203 <system_message level="4" line="1" source="test data" type="SEVERE">
205 Missing matching underline for section title overline.
206 <literal_block xml:space="preserve">
210 Test missing underline, with paragraph.
217 Test long title and space normalization.
220 <document source="test data">
221 <section ids="long-title" names="long\ title">
224 <system_message level="2" line="1" source="test data" type="WARNING">
226 Title overline too short.
227 <literal_block xml:space="preserve">
232 Test long title and space normalization.
242 <document source="test data">
243 <system_message level="4" line="1" source="test data" type="SEVERE">
245 Title overline & underline mismatch.
246 <literal_block xml:space="preserve">
254 ========================
256 ========================
258 Test missing titles; blank line in-between.
260 ========================
262 ========================
265 <document source="test data">
269 Test missing titles; blank line in-between.
274 ========================
275 ========================
277 Test missing titles; nothing in-between.
279 ========================
280 ========================
283 <document source="test data">
284 <system_message level="3" line="1" source="test data" type="ERROR">
286 Invalid section title or transition marker.
287 <literal_block xml:space="preserve">
288 ========================
289 ========================
291 Test missing titles; nothing in-between.
292 <system_message level="3" line="6" source="test data" type="ERROR">
294 Invalid section title or transition marker.
295 <literal_block xml:space="preserve">
296 ========================
297 ========================
300 .. Test return to existing, highest-level section (Title 3).
319 <document source="test data">
320 <comment xml:space="preserve">
321 Test return to existing, highest-level section (Title 3).
322 <section ids="title-1" names="title\ 1">
327 <section ids="title-2" names="title\ 2">
332 <section ids="title-3" names="title\ 3">
337 <section ids="title-4" names="title\ 4">
344 Test return to existing, highest-level section (Title 3, with overlines).
367 <document source="test data">
369 Test return to existing, highest-level section (Title 3, with overlines).
370 <section ids="title-1" names="title\ 1">
375 <section ids="title-2" names="title\ 2">
380 <section ids="title-3" names="title\ 3">
385 <section ids="title-4" names="title\ 4">
392 Test return to existing, higher-level section (Title 4).
411 <document source="test data">
413 Test return to existing, higher-level section (Title 4).
414 <section ids="title-1" names="title\ 1">
419 <section ids="title-2" names="title\ 2">
424 <section ids="title-3" names="title\ 3">
429 <section ids="title-4" names="title\ 4">
436 Test bad subsection order (Title 4).
455 <document source="test data">
457 Test bad subsection order (Title 4).
458 <section ids="title-1" names="title\ 1">
463 <section ids="title-2" names="title\ 2">
468 <section ids="title-3" names="title\ 3">
473 <system_message level="4" line="15" source="test data" type="SEVERE">
475 Title level inconsistent:
476 <literal_block xml:space="preserve">
483 Test bad subsection order (Title 4, with overlines).
506 <document source="test data">
508 Test bad subsection order (Title 4, with overlines).
509 <section ids="title-1" names="title\ 1">
514 <section ids="title-2" names="title\ 2">
519 <section ids="title-3" names="title\ 3">
524 <system_message level="4" line="19" source="test data" type="SEVERE">
526 Title level inconsistent:
527 <literal_block xml:space="preserve">
535 Title containing *inline* ``markup``
536 ====================================
541 <document source="test data">
542 <section ids="title-containing-inline-markup" names="title\ containing\ inline\ markup">
560 <document source="test data">
561 <section ids="numbered-title" names="1.\ numbered\ title">
576 <document source="test data">
577 <enumerated_list enumtype="arabic" prefix="" suffix=".">
584 <system_message level="2" line="3" source="test data" type="WARNING">
586 Enumerated list ends without a blank line; unexpected unindent.
587 <section ids="numbered-title" names="3.\ numbered\ title">
600 <document source="test data">
601 <section ids="abc" names="abc">
614 <document source="test data">
615 <system_message level="1" line="2" source="test data" type="INFO">
617 Possible title underline, too short for the title.
618 Treating it as ordinary text because it's so short.
630 Over & underline too short.
633 <document source="test data">
634 <system_message level="1" line="1" source="test data" type="INFO">
636 Possible incomplete section title.
637 Treating the overline as ordinary text because it's so short.
643 Over & underline too short.
649 Overline too short, no underline.
652 <document source="test data">
653 <system_message level="1" line="1" source="test data" type="INFO">
655 Possible incomplete section title.
656 Treating the overline as ordinary text because it's so short.
661 Overline too short, no underline.
668 <document source="test data">
669 <system_message level="1" line="1" source="test data" type="INFO">
671 Possible incomplete section title.
672 Treating the overline as ordinary text because it's so short.
679 Not a title: a definition list item.
682 <document source="test data">
683 <system_message level="1" line="1" source="test data" type="INFO">
685 Possible incomplete section title.
686 Treating the overline as ordinary text because it's so short.
688 <definition_list_item>
693 Not a title: a definition list item.
697 Not a title: a definition list item.
699 Another definition list item. It's in a different list,
700 but that's an acceptable limitation given that this will
701 probably never happen in real life.
703 The next line will trigger a warning:
707 <document source="test data">
708 <system_message level="1" line="1" source="test data" type="INFO">
710 Possible incomplete section title.
711 Treating the overline as ordinary text because it's so short.
713 <definition_list_item>
718 Not a title: a definition list item.
719 <system_message level="2" line="3" source="test data" type="WARNING">
721 Definition list ends without a blank line; unexpected unindent.
722 <system_message level="1" line="3" source="test data" type="INFO">
724 Possible incomplete section title.
725 Treating the overline as ordinary text because it's so short.
727 <definition_list_item>
732 Another definition list item. It's in a different list,
733 but that's an acceptable limitation given that this will
734 probably never happen in real life.
736 The next line will trigger a warning:
737 <system_message level="2" line="9" source="test data" type="WARNING">
739 Definition list ends without a blank line; unexpected unindent.
750 Over & underline too short.
753 <document source="test data">
757 <system_message level="1" line="3" source="test data" type="INFO">
759 Unexpected possible title overline or transition.
760 Treating it as ordinary text because it's so short.
766 Over & underline too short.
777 <document source="test data">
799 <document source="test data">
800 <system_message level="1" line="1" source="test data" type="INFO">
802 Possible incomplete section title.
803 Treating the overline as ordinary text because it's so short.
804 <section dupnames="..." ids="id1">
807 <system_message level="1" line="4" source="test data" type="INFO">
809 Possible incomplete section title.
810 Treating the overline as ordinary text because it's so short.
811 <section dupnames="..." ids="id2">
814 <system_message backrefs="id2" level="1" line="5" source="test data" type="INFO">
816 Duplicate implicit target name: "...".
817 <system_message level="1" line="7" source="test data" type="INFO">
819 Possible incomplete section title.
820 Treating the overline as ordinary text because it's so short.
821 <system_message level="1" line="7" source="test data" type="INFO">
823 Possible incomplete section title.
824 Treating the overline as ordinary text because it's so short.
825 <section dupnames="..." ids="id3">
828 <system_message backrefs="id3" level="1" line="8" source="test data" type="INFO">
830 Duplicate implicit target name: "...".
846 <document source="test data">
847 <comment xml:space="preserve">
848 <system_message level="2" line="2" source="test data" type="WARNING">
850 Explicit markup ends without a blank line; unexpected unindent.
851 <section ids="hi" names="hi">
854 <section ids="yo" names="yo">
865 <document source="test data">
866 <section ids="empty-section" names="empty\ section">
875 The bubble-up parser strategy conflicts with short titles
876 (<= 3 char-long over- & underlines).
882 The parser currently contains a work-around kludge.
883 Without it, the parser ends up in an infinite loop.
886 <document source="test data">
887 <section ids="one" names="one">
891 The bubble-up parser strategy conflicts with short titles
892 (<= 3 char-long over- & underlines).
893 <section ids="two" names="two">
897 The parser currently contains a work-around kludge.
898 Without it, the parser ends up in an infinite loop.
903 <document source="test data">
908 if __name__
== '__main__':
910 unittest
.main(defaultTest
='suite')