Spelling fixes
[docutils.git] / test / test_parsers / test_rst / test_enumerated_lists.py
blob38bf2268c0934fd7d2a477fb2a1cfd04158f4e92
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['enumerated_lists'] = [
21 ["""\
22 1. Item one.
24 2. Item two.
26 3. Item three.
27 """,
28 """\
29 <document source="test data">
30 <enumerated_list enumtype="arabic" prefix="" suffix=".">
31 <list_item>
32 <paragraph>
33 Item one.
34 <list_item>
35 <paragraph>
36 Item two.
37 <list_item>
38 <paragraph>
39 Item three.
40 """],
41 ["""\
42 No blank lines betwen items:
44 1. Item one.
45 2. Item two.
46 3. Item three.
47 """,
48 """\
49 <document source="test data">
50 <paragraph>
51 No blank lines betwen items:
52 <enumerated_list enumtype="arabic" prefix="" suffix=".">
53 <list_item>
54 <paragraph>
55 Item one.
56 <list_item>
57 <paragraph>
58 Item two.
59 <list_item>
60 <paragraph>
61 Item three.
62 """],
63 ["""\
65 empty item above, no blank line
66 """,
67 """\
68 <document source="test data">
69 <paragraph>
71 empty item above, no blank line
72 """],
73 ["""\
74 Scrambled:
76 3. Item three.
78 2. Item two.
80 1. Item one.
82 3. Item three.
83 2. Item two.
84 1. Item one.
85 """,
86 """\
87 <document source="test data">
88 <paragraph>
89 Scrambled:
90 <enumerated_list enumtype="arabic" prefix="" start="3" suffix=".">
91 <list_item>
92 <paragraph>
93 Item three.
94 <system_message level="1" line="3" source="test data" type="INFO">
95 <paragraph>
96 Enumerated list start value not ordinal-1: "3" (ordinal 3)
97 <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
98 <list_item>
99 <paragraph>
100 Item two.
101 <system_message level="1" line="5" source="test data" type="INFO">
102 <paragraph>
103 Enumerated list start value not ordinal-1: "2" (ordinal 2)
104 <enumerated_list enumtype="arabic" prefix="" suffix=".">
105 <list_item>
106 <paragraph>
107 Item one.
108 <paragraph>
109 3. Item three.
110 2. Item two.
111 1. Item one.
112 """],
113 ["""\
114 Skipping item 3:
116 1. Item 1.
117 2. Item 2.
118 4. Item 4.
119 """,
120 """\
121 <document source="test data">
122 <paragraph>
123 Skipping item 3:
124 <enumerated_list enumtype="arabic" prefix="" suffix=".">
125 <list_item>
126 <paragraph>
127 Item 1.
128 <system_message level="2" line="4" source="test data" type="WARNING">
129 <paragraph>
130 Enumerated list ends without a blank line; unexpected unindent.
131 <paragraph>
132 2. Item 2.
133 4. Item 4.
134 """],
135 ["""\
136 Start with non-ordinal-1:
138 0. Item zero.
139 1. Item one.
140 2. Item two.
141 3. Item three.
143 And again:
145 2. Item two.
146 3. Item three.
147 """,
148 """\
149 <document source="test data">
150 <paragraph>
151 Start with non-ordinal-1:
152 <enumerated_list enumtype="arabic" prefix="" start="0" suffix=".">
153 <list_item>
154 <paragraph>
155 Item zero.
156 <list_item>
157 <paragraph>
158 Item one.
159 <list_item>
160 <paragraph>
161 Item two.
162 <list_item>
163 <paragraph>
164 Item three.
165 <system_message level="1" line="3" source="test data" type="INFO">
166 <paragraph>
167 Enumerated list start value not ordinal-1: "0" (ordinal 0)
168 <paragraph>
169 And again:
170 <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
171 <list_item>
172 <paragraph>
173 Item two.
174 <list_item>
175 <paragraph>
176 Item three.
177 <system_message level="1" line="10" source="test data" type="INFO">
178 <paragraph>
179 Enumerated list start value not ordinal-1: "2" (ordinal 2)
180 """],
181 ["""\
182 1. Item one: line 1,
183 line 2.
184 2. Item two: line 1,
185 line 2.
186 3. Item three: paragraph 1, line 1,
187 line 2.
189 Paragraph 2.
190 """,
191 """\
192 <document source="test data">
193 <enumerated_list enumtype="arabic" prefix="" suffix=".">
194 <list_item>
195 <paragraph>
196 Item one: line 1,
197 line 2.
198 <list_item>
199 <paragraph>
200 Item two: line 1,
201 line 2.
202 <list_item>
203 <paragraph>
204 Item three: paragraph 1, line 1,
205 line 2.
206 <paragraph>
207 Paragraph 2.
208 """],
209 ["""\
210 Different enumeration sequences:
212 1. Item 1.
213 2. Item 2.
214 3. Item 3.
216 A. Item A.
217 B. Item B.
218 C. Item C.
220 a. Item a.
221 b. Item b.
222 c. Item c.
224 I. Item I.
225 II. Item II.
226 III. Item III.
228 i. Item i.
229 ii. Item ii.
230 iii. Item iii.
231 """,
232 """\
233 <document source="test data">
234 <paragraph>
235 Different enumeration sequences:
236 <enumerated_list enumtype="arabic" prefix="" suffix=".">
237 <list_item>
238 <paragraph>
239 Item 1.
240 <list_item>
241 <paragraph>
242 Item 2.
243 <list_item>
244 <paragraph>
245 Item 3.
246 <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
247 <list_item>
248 <paragraph>
249 Item A.
250 <list_item>
251 <paragraph>
252 Item B.
253 <list_item>
254 <paragraph>
255 Item C.
256 <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
257 <list_item>
258 <paragraph>
259 Item a.
260 <list_item>
261 <paragraph>
262 Item b.
263 <list_item>
264 <paragraph>
265 Item c.
266 <enumerated_list enumtype="upperroman" prefix="" suffix=".">
267 <list_item>
268 <paragraph>
269 Item I.
270 <list_item>
271 <paragraph>
272 Item II.
273 <list_item>
274 <paragraph>
275 Item III.
276 <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
277 <list_item>
278 <paragraph>
279 Item i.
280 <list_item>
281 <paragraph>
282 Item ii.
283 <list_item>
284 <paragraph>
285 Item iii.
286 """],
287 ["""\
288 Bad Roman numerals:
290 i. i
292 ii. ii
294 iii. iii
296 iiii. iiii
297 second line
299 (LCD) is an acronym made up of Roman numerals
301 (livid) is a word made up of Roman numerals
303 (CIVIL) is another such word
305 (I) I
307 (IVXLCDM) IVXLCDM
308 """,
309 """\
310 <document source="test data">
311 <paragraph>
312 Bad Roman numerals:
313 <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
314 <list_item>
315 <paragraph>
317 <list_item>
318 <paragraph>
320 <list_item>
321 <paragraph>
323 <definition_list>
324 <definition_list_item>
325 <term>
326 iiii. iiii
327 <definition>
328 <paragraph>
329 second line
330 <paragraph>
331 (LCD) is an acronym made up of Roman numerals
332 <paragraph>
333 (livid) is a word made up of Roman numerals
334 <paragraph>
335 (CIVIL) is another such word
336 <enumerated_list enumtype="upperroman" prefix="(" suffix=")">
337 <list_item>
338 <paragraph>
340 <paragraph>
341 (IVXLCDM) IVXLCDM
342 """],
343 ["""\
344 Potentially ambiguous cases:
346 A. Item A.
347 B. Item B.
348 C. Item C.
350 I. Item I.
351 II. Item II.
352 III. Item III.
354 a. Item a.
355 b. Item b.
356 c. Item c.
358 i. Item i.
359 ii. Item ii.
360 iii. Item iii.
362 Phew! Safe!
363 """,
364 """\
365 <document source="test data">
366 <paragraph>
367 Potentially ambiguous cases:
368 <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
369 <list_item>
370 <paragraph>
371 Item A.
372 <list_item>
373 <paragraph>
374 Item B.
375 <list_item>
376 <paragraph>
377 Item C.
378 <enumerated_list enumtype="upperroman" prefix="" suffix=".">
379 <list_item>
380 <paragraph>
381 Item I.
382 <list_item>
383 <paragraph>
384 Item II.
385 <list_item>
386 <paragraph>
387 Item III.
388 <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
389 <list_item>
390 <paragraph>
391 Item a.
392 <list_item>
393 <paragraph>
394 Item b.
395 <list_item>
396 <paragraph>
397 Item c.
398 <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
399 <list_item>
400 <paragraph>
401 Item i.
402 <list_item>
403 <paragraph>
404 Item ii.
405 <list_item>
406 <paragraph>
407 Item iii.
408 <paragraph>
409 Phew! Safe!
410 """],
411 ["""\
412 Definitely ambiguous:
414 A. Item A.
415 B. Item B.
416 C. Item C.
417 D. Item D.
418 E. Item E.
419 F. Item F.
420 G. Item G.
421 H. Item H.
422 I. Item I.
423 II. Item II.
424 III. Item III.
426 a. Item a.
427 b. Item b.
428 c. Item c.
429 d. Item d.
430 e. Item e.
431 f. Item f.
432 g. Item g.
433 h. Item h.
434 i. Item i.
435 ii. Item ii.
436 iii. Item iii.
437 """,
438 """\
439 <document source="test data">
440 <paragraph>
441 Definitely ambiguous:
442 <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
443 <list_item>
444 <paragraph>
445 Item A.
446 <list_item>
447 <paragraph>
448 Item B.
449 <list_item>
450 <paragraph>
451 Item C.
452 <list_item>
453 <paragraph>
454 Item D.
455 <list_item>
456 <paragraph>
457 Item E.
458 <list_item>
459 <paragraph>
460 Item F.
461 <list_item>
462 <paragraph>
463 Item G.
464 <list_item>
465 <paragraph>
466 Item H.
467 <system_message level="2" line="11" source="test data" type="WARNING">
468 <paragraph>
469 Enumerated list ends without a blank line; unexpected unindent.
470 <enumerated_list enumtype="upperroman" prefix="" suffix=".">
471 <list_item>
472 <paragraph>
473 Item I.
474 <list_item>
475 <paragraph>
476 Item II.
477 <list_item>
478 <paragraph>
479 Item III.
480 <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
481 <list_item>
482 <paragraph>
483 Item a.
484 <list_item>
485 <paragraph>
486 Item b.
487 <list_item>
488 <paragraph>
489 Item c.
490 <list_item>
491 <paragraph>
492 Item d.
493 <list_item>
494 <paragraph>
495 Item e.
496 <list_item>
497 <paragraph>
498 Item f.
499 <list_item>
500 <paragraph>
501 Item g.
502 <list_item>
503 <paragraph>
504 Item h.
505 <system_message level="2" line="23" source="test data" type="WARNING">
506 <paragraph>
507 Enumerated list ends without a blank line; unexpected unindent.
508 <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
509 <list_item>
510 <paragraph>
511 Item i.
512 <list_item>
513 <paragraph>
514 Item ii.
515 <list_item>
516 <paragraph>
517 Item iii.
518 """],
519 ["""\
520 Different enumeration formats:
522 1. Item 1.
523 2. Item 2.
524 3. Item 3.
526 1) Item 1).
527 2) Item 2).
528 3) Item 3).
530 (1) Item (1).
531 (2) Item (2).
532 (3) Item (3).
533 """,
534 """\
535 <document source="test data">
536 <paragraph>
537 Different enumeration formats:
538 <enumerated_list enumtype="arabic" prefix="" suffix=".">
539 <list_item>
540 <paragraph>
541 Item 1.
542 <list_item>
543 <paragraph>
544 Item 2.
545 <list_item>
546 <paragraph>
547 Item 3.
548 <enumerated_list enumtype="arabic" prefix="" suffix=")">
549 <list_item>
550 <paragraph>
551 Item 1).
552 <list_item>
553 <paragraph>
554 Item 2).
555 <list_item>
556 <paragraph>
557 Item 3).
558 <enumerated_list enumtype="arabic" prefix="(" suffix=")">
559 <list_item>
560 <paragraph>
561 Item (1).
562 <list_item>
563 <paragraph>
564 Item (2).
565 <list_item>
566 <paragraph>
567 Item (3).
568 """],
569 ["""\
570 Nested enumerated lists:
572 1. Item 1.
574 A) Item A).
575 B) Item B).
576 C) Item C).
578 2. Item 2.
580 (a) Item (a).
582 I) Item I).
583 II) Item II).
584 III) Item III).
586 (b) Item (b).
588 (c) Item (c).
590 (i) Item (i).
591 (ii) Item (ii).
592 (iii) Item (iii).
594 3. Item 3.
595 """,
596 """\
597 <document source="test data">
598 <paragraph>
599 Nested enumerated lists:
600 <enumerated_list enumtype="arabic" prefix="" suffix=".">
601 <list_item>
602 <paragraph>
603 Item 1.
604 <enumerated_list enumtype="upperalpha" prefix="" suffix=")">
605 <list_item>
606 <paragraph>
607 Item A).
608 <list_item>
609 <paragraph>
610 Item B).
611 <list_item>
612 <paragraph>
613 Item C).
614 <list_item>
615 <paragraph>
616 Item 2.
617 <enumerated_list enumtype="loweralpha" prefix="(" suffix=")">
618 <list_item>
619 <paragraph>
620 Item (a).
621 <enumerated_list enumtype="upperroman" prefix="" suffix=")">
622 <list_item>
623 <paragraph>
624 Item I).
625 <list_item>
626 <paragraph>
627 Item II).
628 <list_item>
629 <paragraph>
630 Item III).
631 <list_item>
632 <paragraph>
633 Item (b).
634 <list_item>
635 <paragraph>
636 Item (c).
637 <enumerated_list enumtype="lowerroman" prefix="(" suffix=")">
638 <list_item>
639 <paragraph>
640 Item (i).
641 <list_item>
642 <paragraph>
643 Item (ii).
644 <list_item>
645 <paragraph>
646 Item (iii).
647 <list_item>
648 <paragraph>
649 Item 3.
650 """],
651 [u"""\
652 A. Einstein was a great influence on
653 B. Physicist, who was a colleague of
654 C. Chemist. They all worked in
655 Princeton, NJ.
657 Using a non-breaking space as a workaround:
659 A.\u00a0Einstein was a great influence on
660 B. Physicist, who was a colleague of
661 C. Chemist. They all worked in
662 Princeton, NJ.
663 """,
664 """\
665 <document source="test data">
666 <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
667 <list_item>
668 <paragraph>
669 Einstein was a great influence on
670 <list_item>
671 <paragraph>
672 Physicist, who was a colleague of
673 <system_message level="2" line="3" source="test data" type="WARNING">
674 <paragraph>
675 Enumerated list ends without a blank line; unexpected unindent.
676 <paragraph>
677 C. Chemist. They all worked in
678 Princeton, NJ.
679 <paragraph>
680 Using a non-breaking space as a workaround:
681 <paragraph>
682 A.\xa0Einstein was a great influence on
683 B. Physicist, who was a colleague of
684 C. Chemist. They all worked in
685 Princeton, NJ.
686 """],
687 ["""\
688 1. Item one: line 1,
689 line 2.
690 2. Item two: line 1,
691 line 2.
692 3. Item three: paragraph 1, line 1,
693 line 2.
695 Paragraph 2.
696 """,
697 """\
698 <document source="test data">
699 <enumerated_list enumtype="arabic" prefix="" suffix=".">
700 <list_item>
701 <paragraph>
702 Item one: line 1,
703 line 2.
704 <list_item>
705 <paragraph>
706 Item two: line 1,
707 <system_message level="2" line="4" source="test data" type="WARNING">
708 <paragraph>
709 Enumerated list ends without a blank line; unexpected unindent.
710 <block_quote>
711 <paragraph>
712 line 2.
713 <system_message level="2" line="5" source="test data" type="WARNING">
714 <paragraph>
715 Block quote ends without a blank line; unexpected unindent.
716 <enumerated_list enumtype="arabic" prefix="" start="3" suffix=".">
717 <list_item>
718 <paragraph>
719 Item three: paragraph 1, line 1,
720 <system_message level="1" line="5" source="test data" type="INFO">
721 <paragraph>
722 Enumerated list start value not ordinal-1: "3" (ordinal 3)
723 <system_message level="2" line="6" source="test data" type="WARNING">
724 <paragraph>
725 Enumerated list ends without a blank line; unexpected unindent.
726 <block_quote>
727 <paragraph>
728 line 2.
729 <block_quote>
730 <paragraph>
731 Paragraph 2.
732 """],
733 ["""\
734 1. Item one.
736 #. Item two.
738 #. Item three.
739 """,
740 """\
741 <document source="test data">
742 <enumerated_list enumtype="arabic" prefix="" suffix=".">
743 <list_item>
744 <paragraph>
745 Item one.
746 <list_item>
747 <paragraph>
748 Item two.
749 <list_item>
750 <paragraph>
751 Item three.
752 """],
753 ["""\
754 a. Item one.
755 #. Item two.
756 #. Item three.
757 """,
758 """\
759 <document source="test data">
760 <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
761 <list_item>
762 <paragraph>
763 Item one.
764 <list_item>
765 <paragraph>
766 Item two.
767 <list_item>
768 <paragraph>
769 Item three.
770 """],
771 ["""\
772 i. Item one.
773 ii. Item two.
774 #. Item three.
775 """,
776 """\
777 <document source="test data">
778 <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
779 <list_item>
780 <paragraph>
781 Item one.
782 <list_item>
783 <paragraph>
784 Item two.
785 <list_item>
786 <paragraph>
787 Item three.
788 """],
789 ["""\
790 #. Item one.
791 #. Item two.
792 #. Item three.
793 """,
794 """\
795 <document source="test data">
796 <enumerated_list enumtype="arabic" prefix="" suffix=".">
797 <list_item>
798 <paragraph>
799 Item one.
800 <list_item>
801 <paragraph>
802 Item two.
803 <list_item>
804 <paragraph>
805 Item three.
806 """],
807 ["""\
808 1. Item one.
809 #. Item two.
810 3. Item three.
811 """,
812 """\
813 <document source="test data">
814 <enumerated_list enumtype="arabic" prefix="" suffix=".">
815 <list_item>
816 <paragraph>
817 Item one.
818 <system_message level="2" line="2" source="test data" type="WARNING">
819 <paragraph>
820 Enumerated list ends without a blank line; unexpected unindent.
821 <paragraph>
822 #. Item two.
823 3. Item three.
824 """],
825 ["""\
828 """,
829 """\
830 <document source="test data">
831 <paragraph>
834 """],
835 ["""\
836 3-space indent, with a trailing space:
838 1. \n\
841 3-space indent, no trailing space:
846 2-space indent:
851 1-space indent:
856 0-space indent, not a list item:
861 No item content:
864 """,
865 """\
866 <document source="test data">
867 <paragraph>
868 3-space indent, with a trailing space:
869 <enumerated_list enumtype="arabic" prefix="" suffix=".">
870 <list_item>
871 <paragraph>
873 <paragraph>
874 3-space indent, no trailing space:
875 <enumerated_list enumtype="arabic" prefix="" suffix=".">
876 <list_item>
877 <paragraph>
879 <paragraph>
880 2-space indent:
881 <enumerated_list enumtype="arabic" prefix="" suffix=".">
882 <list_item>
883 <paragraph>
885 <paragraph>
886 1-space indent:
887 <enumerated_list enumtype="arabic" prefix="" suffix=".">
888 <list_item>
889 <paragraph>
891 <paragraph>
892 0-space indent, not a list item:
893 <paragraph>
896 <paragraph>
897 No item content:
898 <enumerated_list enumtype="arabic" prefix="" suffix=".">
899 <list_item>
900 """],
904 if __name__ == '__main__':
905 import unittest
906 unittest.main(defaultTest='suite')