Backwards-compatible fix for system-exit on IOError.
[docutils.git] / test / test_parsers / test_rst / test_directives / test_include.py
blob168d452f6003766ee5aa0733148802d44f8a179f
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 misc.py "include" directive.
9 """
11 import os.path
12 import sys
13 from __init__ import DocutilsTestSupport
14 from docutils.parsers.rst import states
15 from docutils._compat import b
16 from docutils.utils.code_analyzer import with_pygments
18 def suite():
19 s = DocutilsTestSupport.ParserTestSuite()
20 if not with_pygments:
21 del(totest['include-code'])
22 s.generateTests(totest)
23 return s
25 # prepend this directory (relative to the test root):
26 def mydir(path):
27 return os.path.join('test_parsers/test_rst/test_directives/', path)
28 # make `path` relative with utils.relative_path():
29 def reldir(path):
30 return DocutilsTestSupport.utils.relative_path(None, path)
32 include1 = mydir('include1.txt')
33 include2 = mydir('include2.txt')
34 include3 = mydir('include3.txt')
35 include8 = mydir('include8.txt')
36 include10 = mydir('include10.txt')
37 include11 = mydir('include 11.txt')
38 include12 = mydir('include12.txt')
39 include13 = mydir('include13.txt')
40 include_literal = mydir('include_literal.txt')
41 utf_16_file = mydir('utf-16.csv')
42 utf_16_error_str = ("UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe "
43 "in position 0: ordinal not in range(128)")
44 if sys.version_info < (3,0):
45 utf_16_error_str = ("UnicodeError: Unable to decode input data. "
46 "Tried the following encodings: 'ascii'.\n"
47 " (%s)" % utf_16_error_str)
48 nonexistent = os.path.join(os.path.dirname(states.__file__),
49 'include', 'nonexistent')
50 nonexistent_rel = DocutilsTestSupport.utils.relative_path(
51 os.path.join(DocutilsTestSupport.testroot, 'dummy'), nonexistent)
53 totest = {}
55 totest['include'] = [
56 ["""\
57 Include Test
58 ============
60 .. include:: %s
62 A paragraph.
63 """ % include1,
64 """\
65 <document source="test data">
66 <section ids="include-test" names="include\ test">
67 <title>
68 Include Test
69 <section ids="inclusion-1" names="inclusion\ 1">
70 <title>
71 Inclusion 1
72 <paragraph>
73 This file is used by \n\
74 <literal>
75 test_include.py
77 <paragraph>
78 A paragraph.
79 """],
80 ["""\
81 Include Test
82 ============
84 .. include:: %s
85 :literal:
86 :class: test
87 :name: my name
89 A paragraph.
90 """ % include1,
91 """\
92 <document source="test data">
93 <section ids="include-test" names="include\ test">
94 <title>
95 Include Test
96 <literal_block classes="test" ids="my-name" names="my\ name" source="%s" xml:space="preserve">
97 Inclusion 1
98 -----------
99 \n\
100 This file is used by ``test_include.py``.
101 <paragraph>
102 A paragraph.
103 """ % reldir(include1)],
104 ["""\
105 Literal include, add line numbers
107 .. include:: %s
108 :literal:
109 :number-lines:
110 """ % include1,
111 """\
112 <document source="test data">
113 <paragraph>
114 Literal include, add line numbers
115 <literal_block source="%s" xml:space="preserve">
116 <inline classes="ln">
117 1 \n\
118 Inclusion 1
119 <inline classes="ln">
120 2 \n\
121 -----------
122 <inline classes="ln">
123 3 \n\
125 <inline classes="ln">
126 4 \n\
127 This file is used by ``test_include.py``.
128 """ % reldir(include1)],
129 ["""\
130 Include code
132 .. include:: %s
133 :code:
134 :class: test
135 :name: my name
136 """ % include1,
137 """\
138 <document source="test data">
139 <paragraph>
140 Include code
141 <literal_block classes="code test" ids="my-name" names="my\ name" source="%s" xml:space="preserve">
142 Inclusion 1
143 -----------
145 This file is used by ``test_include.py``.
146 """ % reldir(include1)],
147 ["""\
148 Include code, add line numbers
150 .. include:: %s
151 :code:
152 :number-lines:
153 """ % include1,
154 """\
155 <document source="test data">
156 <paragraph>
157 Include code, add line numbers
158 <literal_block classes="code" source="%s" xml:space="preserve">
159 <inline classes="ln">
160 1 \n\
161 Inclusion 1
162 <inline classes="ln">
163 2 \n\
164 -----------
165 <inline classes="ln">
166 3 \n\
168 <inline classes="ln">
169 4 \n\
170 This file is used by ``test_include.py``.
171 """ % reldir(include1)],
172 ["""\
173 Let's test the parse context.
175 This paragraph is in a block quote.
177 .. include:: %s
179 The included paragraphs should also be in the block quote.
180 """ % include2,
181 """\
182 <document source="test data">
183 <paragraph>
184 Let's test the parse context.
185 <block_quote>
186 <paragraph>
187 This paragraph is in a block quote.
188 <paragraph>
189 Here are some paragraphs
190 that can appear at any level.
191 <paragraph>
192 This file (include2.txt) is used by
193 <literal>
194 test_include.py
196 <paragraph>
197 The included paragraphs should also be in the block quote.
198 """],
199 ["""\
200 Include Test
201 ============
203 .. include:: nonexistent.txt
205 A paragraph.
206 """,
207 """\
208 <document source="test data">
209 <section ids="include-test" names="include\ test">
210 <title>
211 Include Test
212 <system_message level="4" line="4" source="test data" type="SEVERE">
213 <paragraph>
214 Problems with "include" directive path:
215 InputError: [Errno 2] No such file or directory: 'nonexistent.txt'.
216 <literal_block xml:space="preserve">
217 .. include:: nonexistent.txt
218 <paragraph>
219 A paragraph.
220 """],
221 ["""\
222 Include Test
223 ============
225 .. include:: %s
227 .. include:: %s
229 A paragraph.
230 """ % (include1, include1),
231 """\
232 <document source="test data">
233 <section ids="include-test" names="include\ test">
234 <title>
235 Include Test
236 <section dupnames="inclusion\ 1" ids="inclusion-1">
237 <title>
238 Inclusion 1
239 <paragraph>
240 This file is used by
241 <literal>
242 test_include.py
244 <section dupnames="inclusion\ 1" ids="id1">
245 <title>
246 Inclusion 1
247 <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO">
248 <paragraph>
249 Duplicate implicit target name: "inclusion 1".
250 <paragraph>
251 This file is used by
252 <literal>
253 test_include.py
255 <paragraph>
256 A paragraph.
257 """ % reldir(include1)],
258 ["""\
259 Include Test
260 ============
262 .. include:: %s
264 ----------
266 .. include:: %s
268 A paragraph.
269 """ % (include1, include1),
270 """\
271 <document source="test data">
272 <section ids="include-test" names="include\ test">
273 <title>
274 Include Test
275 <section dupnames="inclusion\ 1" ids="inclusion-1">
276 <title>
277 Inclusion 1
278 <paragraph>
279 This file is used by \n\
280 <literal>
281 test_include.py
283 <transition>
284 <section dupnames="inclusion\ 1" ids="id1">
285 <title>
286 Inclusion 1
287 <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO">
288 <paragraph>
289 Duplicate implicit target name: "inclusion 1".
290 <paragraph>
291 This file is used by \n\
292 <literal>
293 test_include.py
295 <paragraph>
296 A paragraph.
297 """ % reldir(include1)],
298 ["""\
299 In test data
301 .. include:: %s
302 """ % include3,
303 """\
304 <document source="test data">
305 <paragraph>
306 In test data
307 <paragraph>
308 In include3.txt
309 <paragraph>
310 In includes/include4.txt
311 <paragraph>
312 In includes/include5.txt
313 <paragraph>
314 In includes/more/include6.txt
315 <paragraph>
316 In includes/sibling/include7.txt
317 """],
318 ["""\
319 In test data
321 Section
322 =======
324 (Section contents in nested parse; slice of input_lines ViewList.)
326 .. include:: %s
327 """ % include3,
328 """\
329 <document source="test data">
330 <paragraph>
331 In test data
332 <section ids="section" names="section">
333 <title>
334 Section
335 <paragraph>
336 (Section contents in nested parse; slice of input_lines ViewList.)
337 <paragraph>
338 In include3.txt
339 <paragraph>
340 In includes/include4.txt
341 <paragraph>
342 In includes/include5.txt
343 <paragraph>
344 In includes/more/include6.txt
345 <paragraph>
346 In includes/sibling/include7.txt
347 """],
348 ["""\
349 Testing relative includes:
351 .. include:: %s
352 """ % include8,
353 """\
354 <document source="test data">
355 <paragraph>
356 Testing relative includes:
357 <paragraph>
358 In include8.txt
359 <paragraph>
360 In ../includes/include9.txt.
361 <paragraph>
362 Here are some paragraphs
363 that can appear at any level.
364 <paragraph>
365 This file (include2.txt) is used by
366 <literal>
367 test_include.py
369 """],
370 ["""\
371 Encoding:
373 .. include:: %s
374 :encoding: utf-16
375 """ % reldir(utf_16_file),
376 b("""\
377 <document source="test data">
378 <paragraph>
379 Encoding:
380 <paragraph>
381 "Treat", "Quantity", "Description"
382 "Albatr\xb0\xdf", 2.99, "\xa1On a \\u03c3\\u03c4\\u03b9\\u03ba!"
383 "Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
384 crunchy, now would it?"
385 "Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
386 """).decode('raw_unicode_escape')],
387 ["""\
388 Include file is UTF-16-encoded, and is not valid ASCII.
390 .. include:: %s
391 :encoding: ascii
392 """ % reldir(utf_16_file),
393 """\
394 <document source="test data">
395 <paragraph>
396 Include file is UTF-16-encoded, and is not valid ASCII.
397 <system_message level="4" line="3" source="test data" type="SEVERE">
398 <paragraph>
399 Problem with "include" directive:
401 <literal_block xml:space="preserve">
402 .. include:: %s
403 :encoding: ascii
404 """ % (utf_16_error_str, reldir(utf_16_file))],
405 [u"""\
406 cyrillic filename:
408 .. include:: \u043c\u0438\u0440.txt
409 """,
410 u"""\
411 <document source="test data">
412 <paragraph>
413 cyrillic filename:
414 <system_message level="4" line="3" source="test data" type="SEVERE">
415 <paragraph>
416 Problems with "include" directive path:
417 InputError: [Errno 2] No such file or directory: '\u043c\u0438\u0440.txt'.
418 <literal_block xml:space="preserve">
419 .. include:: \u043c\u0438\u0440.txt
420 """],
421 ["""\
422 Testing errors in included file:
424 .. include:: %s
425 """ % include10,
426 """\
427 <document source="test data">
428 <paragraph>
429 Testing errors in included file:
430 <system_message level="3" line="1" source="%(source)s" type="ERROR">
431 <paragraph>
432 Invalid character code: 0x11111111
433 %(unichr_exception)s
434 <literal_block xml:space="preserve">
435 unicode:: 0x11111111
436 <system_message level="2" line="1" source="%(source)s" type="WARNING">
437 <paragraph>
438 Substitution definition "bad" empty or invalid.
439 <literal_block xml:space="preserve">
440 .. |bad| unicode:: 0x11111111
441 <section dupnames="hi" ids="hi">
442 <title>
444 <block_quote>
445 <paragraph>
446 indent
447 <system_message level="2" line="7" source="%(source)s" type="WARNING">
448 <paragraph>
449 Block quote ends without a blank line; unexpected unindent.
450 <paragraph>
451 error
452 <section dupnames="hi" ids="id1">
453 <title>
455 <system_message backrefs="id1" level="1" line="10" source="%(source)s" type="INFO">
456 <paragraph>
457 Duplicate implicit target name: "hi".
458 <system_message level="4" line="12" source="%(source)s" type="SEVERE">
459 <paragraph>
460 Problems with "include" directive path:
461 InputError: [Errno 2] No such file or directory: '%(nonexistent)s'.
462 <literal_block xml:space="preserve">
463 .. include:: <nonexistent>
464 <system_message level="3" line="14" source="%(source)s" type="ERROR">
465 <paragraph>
466 Content block expected for the "note" directive; none found.
467 <literal_block xml:space="preserve">
468 .. note::
469 <system_message level="3" line="16" source="%(source)s" type="ERROR">
470 <paragraph>
471 Content block expected for the "admonition" directive; none found.
472 <literal_block xml:space="preserve">
473 .. admonition::
474 without title
475 <system_message level="3" line="19" source="%(source)s" type="ERROR">
476 <paragraph>
477 Content block expected for the "epigraph" directive; none found.
478 <literal_block xml:space="preserve">
479 .. epigraph::
480 <system_message level="3" line="21" source="%(source)s" type="ERROR">
481 <paragraph>
482 Content block expected for the "highlights" directive; none found.
483 <literal_block xml:space="preserve">
484 .. highlights::
485 <system_message level="3" line="23" source="%(source)s" type="ERROR">
486 <paragraph>
487 Content block expected for the "pull-quote" directive; none found.
488 <literal_block xml:space="preserve">
489 .. pull-quote::
490 <system_message level="3" line="25" source="%(source)s" type="ERROR">
491 <paragraph>
492 Invalid context: the "date" directive can only be used within a substitution definition.
493 <literal_block xml:space="preserve">
494 .. date::
495 <paragraph>
496 not a
497 definition list:
498 <system_message level="3" line="29" source="%(source)s" type="ERROR">
499 <paragraph>
500 Unexpected indentation.
501 <block_quote>
502 <paragraph>
503 as a term may only be one line long.
504 <system_message level="3" line="31" source="%(source)s" type="ERROR">
505 <paragraph>
506 Error in "admonition" directive:
507 1 argument(s) required, 0 supplied.
508 <literal_block xml:space="preserve">
509 .. admonition::
511 without title and content following a blank line
512 <section ids="section-underline-too-short" names="section\ underline\ too\ short">
513 <title>
514 section underline too short
515 <system_message level="2" line="36" source="%(source)s" type="WARNING">
516 <paragraph>
517 Title underline too short.
518 <literal_block xml:space="preserve">
519 section underline too short
520 -----
521 <table>
522 <tgroup cols="2">
523 <colspec colwidth="14">
524 <colspec colwidth="6">
525 <thead>
526 <row>
527 <entry>
528 <paragraph>
529 A simple table
530 <entry>
531 <paragraph>
532 cell 2
533 <tbody>
534 <row>
535 <entry>
536 <paragraph>
537 cell 3
538 <entry>
539 <paragraph>
540 cell 4
541 <system_message level="2" line="43" source="%(source)s" type="WARNING">
542 <paragraph>
543 Blank line required after table.
544 <paragraph>
545 No blank line after table.
546 <system_message level="3" line="45" source="%(source)s" type="ERROR">
547 <paragraph>
548 Error in "unicode" directive:
549 1 argument(s) required, 0 supplied.
550 <literal_block xml:space="preserve">
551 unicode::
552 <system_message level="2" line="45" source="%(source)s" type="WARNING">
553 <paragraph>
554 Substitution definition "empty" empty or invalid.
555 <literal_block xml:space="preserve">
556 .. |empty| unicode::
557 <system_message level="3" line="47" source="%(source)s" type="ERROR">
558 <paragraph>
559 Error in "topic" directive:
560 1 argument(s) required, 0 supplied.
561 <literal_block xml:space="preserve">
562 .. topic::
563 <system_message level="3" line="49" source="%(source)s" type="ERROR">
564 <paragraph>
565 Error in "rubric" directive:
566 1 argument(s) required, 0 supplied.
567 <literal_block xml:space="preserve">
568 .. rubric::
569 <rubric>
570 A rubric has no content
571 <comment xml:space="preserve">
572 _`target: No matching backquote.
573 <system_message level="2" line="52" source="%(source)s" type="WARNING">
574 <paragraph>
575 malformed hyperlink target.
576 <comment xml:space="preserve">
577 __malformed: no good
578 <system_message level="2" line="53" source="%(source)s" type="WARNING">
579 <paragraph>
580 malformed hyperlink target.
581 <definition_list>
582 <definition_list_item>
583 <term>
584 A literal block::
585 <definition>
586 <system_message level="1" line="57" source="%(source)s" type="INFO">
587 <paragraph>
588 Blank line missing before literal block (after the "::")? Interpreted as a definition list item.
589 <paragraph>
590 with no blank line above.
591 <literal_block xml:space="preserve">
592 > A literal block.
593 <system_message level="3" line="61" source="%(source)s" type="ERROR">
594 <paragraph>
595 Inconsistent literal block quoting.
596 <paragraph>
597 $ with inconsistent quoting.
598 <paragraph>
599 <problematic ids="id3" refid="id2">
600 :unknown-role:`role`
602 and
603 <problematic ids="id5" refid="id4">
605 unbalanced
606 <problematic ids="id7" refid="id6">
608 inline
609 <problematic ids="id9" refid="id8">
611 markup
612 <system_message level="1" line="63" source="%(source)s" type="INFO">
613 <paragraph>
614 No role entry for "unknown-role" in module "docutils.parsers.rst.languages.en".
615 Trying "unknown-role" as canonical role name.
616 <system_message backrefs="id3" ids="id2" level="3" line="63" source="%(source)s" type="ERROR">
617 <paragraph>
618 Unknown interpreted text role "unknown-role".
619 <system_message backrefs="id5" ids="id4" level="2" line="63" source="%(source)s" type="WARNING">
620 <paragraph>
621 Inline emphasis start-string without end-string.
622 <system_message backrefs="id7" ids="id6" level="2" line="63" source="%(source)s" type="WARNING">
623 <paragraph>
624 Inline interpreted text or phrase reference start-string without end-string.
625 <system_message backrefs="id9" ids="id8" level="2" line="63" source="%(source)s" type="WARNING">
626 <paragraph>
627 Inline strong start-string without end-string.
628 <paragraph>
629 <problematic ids="id11" refid="id10">
630 :PEP:`-1`
631 <system_message backrefs="id11" ids="id10" level="3" line="68" source="%(source)s" type="ERROR">
632 <paragraph>
633 PEP number must be a number from 0 to 9999; "-1" is invalid.
634 <system_message level="1" line="66" source="%(source)s" type="INFO">
635 <paragraph>
636 No directive entry for "unknown" in module "docutils.parsers.rst.languages.en".
637 Trying "unknown" as canonical directive name.
638 <system_message level="3" line="70" source="%(source)s" type="ERROR">
639 <paragraph>
640 Unknown directive type "unknown".
641 <literal_block xml:space="preserve">
642 .. unknown:: directive (info still reported with wrong line)
643 <system_message level="3" line="72" source="%(source)s" type="ERROR">
644 <paragraph>
645 Malformed table.
646 No bottom table border found.
647 <literal_block xml:space="preserve">
648 ============== ======
649 A simple table with
650 no bottom border
651 """ % {'source': reldir(include10), 'nonexistent': reldir(nonexistent),
652 'unichr_exception':
653 DocutilsTestSupport.exception_data(unichr, int("11111111", 16))[2]
655 ["""\
656 Include file with whitespace in the path:
658 .. include:: %s
659 """ % reldir(include11),
660 """\
661 <document source="test data">
662 <paragraph>
663 Include file with whitespace in the path:
664 <paragraph>
665 some text
666 """],
667 ["""\
668 Standard include data file:
670 .. include:: <isogrk4.txt>
671 """,
672 b("""\
673 <document source="test data">
674 <paragraph>
675 Standard include data file:
676 <comment xml:space="preserve">
677 This data file has been placed in the public domain.
678 <comment xml:space="preserve">
679 Derived from the Unicode character mappings available from
680 <http://www.w3.org/2003/entities/xml/>.
681 Processed by unicode2rstsubs.py, part of Docutils:
682 <http://docutils.sourceforge.net>.
683 <substitution_definition names="b.Gammad">
684 \\u03dc
685 <substitution_definition names="b.gammad">
686 \\u03dd
687 """).decode('raw_unicode_escape')],
688 ["""\
689 Nonexistent standard include data file:
691 .. include:: <nonexistent>
692 """,
693 """\
694 <document source="test data">
695 <paragraph>
696 Nonexistent standard include data file:
697 <system_message level="4" line="3" source="test data" type="SEVERE">
698 <paragraph>
699 Problems with "include" directive path:
700 InputError: [Errno 2] No such file or directory: '%s'.
701 <literal_block xml:space="preserve">
702 .. include:: <nonexistent>
703 """ % nonexistent_rel],
704 ["""\
705 Include start-line/end-line Test
707 .. include:: %s
708 :start-line: 3
709 :end-line: 4
710 """ % include2,
711 """\
712 <document source="test data">
713 <paragraph>
714 Include start-line/end-line Test
715 <paragraph>
716 This file (include2.txt) is used by
717 """],
718 ["""\
719 Include start-line/end-line + start-after Test
721 .. include:: %s
722 :start-line: 2
723 :end-line: 5
724 :start-after: here
726 Text search is limited to the specified lines.
727 """ % include12,
728 """\
729 <document source="test data">
730 <paragraph>
731 Include start-line/end-line + start-after Test
732 <paragraph>
733 In include12.txt (after "start here", before "stop here")
734 <paragraph>
735 Text search is limited to the specified lines.
736 """],
737 ["""\
738 Include start-after/end-before Test
740 .. include:: %s
741 :start-after: .. start here
742 :end-before: .. stop here
744 A paragraph.
745 """ % include12,
746 """\
747 <document source="test data">
748 <paragraph>
749 Include start-after/end-before Test
750 <paragraph>
751 In include12.txt (after "start here", before "stop here")
752 <paragraph>
753 A paragraph.
754 """],
755 ["""\
756 Include start-after/end-before Test, single option variant
758 .. include:: %s
759 :end-before: .. start here
761 .. include:: %s
762 :start-after: .. stop here
764 A paragraph.
765 """ % (include12, include12),
766 """\
767 <document source="test data">
768 <paragraph>
769 Include start-after/end-before Test, single option variant
770 <paragraph>
771 In include12.txt (but before "start here")
772 <paragraph>
773 In include12.txt (after "stop here")
774 <paragraph>
775 A paragraph.
776 """],
777 ["""\
778 Include start-after/end-before multi-line test.
780 .. include:: %s
781 :start-after: From: me
782 To: you
783 :end-before: -------
784 -- mork of ork
786 .. include:: %s
787 :start-after: From: me
788 To: you
789 :end-before:
790 -------
791 -- mork of ork
793 A paragraph.
794 """ % (include13, include13),
795 """\
796 <document source="test data">
797 <paragraph>
798 Include start-after/end-before multi-line test.
799 <system_message level="4" line="3" source="test data" type="SEVERE">
800 <paragraph>
801 Problem with "end-before" option of "include" directive:
802 Text not found.
803 <literal_block xml:space="preserve">
804 .. include:: %s
805 :start-after: From: me
806 To: you
807 :end-before: -------
808 -- mork of ork
809 <paragraph>
810 In include13.txt (between header and signature)
811 <paragraph>
812 A paragraph.
813 """ % include13],
814 ["""\
815 Error handling test; "end-before" error handling tested in previous test.
817 .. include:: %s
818 :start-after: bad string
819 :end-before: mork of ork
820 """ % include13,
821 """\
822 <document source="test data">
823 <paragraph>
824 Error handling test; "end-before" error handling tested in previous test.
825 <system_message level="4" line="3" source="test data" type="SEVERE">
826 <paragraph>
827 Problem with "start-after" option of "include" directive:
828 Text not found.
829 <literal_block xml:space="preserve">
830 .. include:: %s
831 :start-after: bad string
832 :end-before: mork of ork
833 """ % include13],
834 ["""\
835 TAB expansion with literal include:
837 .. include:: %s
838 :literal:
839 """ % include_literal,
840 """\
841 <document source="test data">
842 <paragraph>
843 TAB expansion with literal include:
844 <literal_block source="%s" xml:space="preserve">
845 Literal included this should **not** be *marked* `up`.
846 <- leading raw tab.
848 Newlines
850 normalized.
851 """ % include_literal],
852 ["""\
853 Custom TAB expansion with literal include:
855 .. include:: %s
856 :literal:
857 :tab-width: 2
858 """ % include_literal,
859 """\
860 <document source="test data">
861 <paragraph>
862 Custom TAB expansion with literal include:
863 <literal_block source="%s" xml:space="preserve">
864 Literal included this should **not** be *marked* `up`.
865 <- leading raw tab.
867 Newlines
869 normalized.
870 """ % include_literal],
871 ["""\
872 No TAB expansion with literal include:
874 .. include:: %s
875 :literal:
876 :tab-width: -1
877 """ % include_literal,
878 """\
879 <document source="test data">
880 <paragraph>
881 No TAB expansion with literal include:
882 <literal_block source="%s" xml:space="preserve">
883 Literal included this should **not** be *marked* `up`.
884 \t<- leading raw tab.
886 Newlines
888 normalized.
889 """ % include_literal],
892 totest['include-code'] = [
893 ["""\
894 Included code
896 .. include:: %s
897 :code: rst
898 """ % include1,
899 """\
900 <document source="test data">
901 <paragraph>
902 Included code
903 <literal_block classes="code rst" source="%s" xml:space="preserve">
904 <inline classes="gh">
905 Inclusion 1
907 <inline classes="gh">
908 -----------
911 This file is used by \n\
912 <inline classes="s">
913 ``test_include.py``
915 """ % reldir(include1)],
916 ["""\
917 Included code
919 .. include:: %s
920 :code: rst
921 :number-lines:
922 """ % include1,
923 """\
924 <document source="test data">
925 <paragraph>
926 Included code
927 <literal_block classes="code rst" source="%s" xml:space="preserve">
928 <inline classes="ln">
929 1 \n\
930 <inline classes="gh">
931 Inclusion 1
933 <inline classes="ln">
934 2 \n\
935 <inline classes="gh">
936 -----------
938 <inline classes="ln">
939 3 \n\
941 <inline classes="ln">
942 4 \n\
943 This file is used by \n\
944 <inline classes="s">
945 ``test_include.py``
947 """ % reldir(include1)],
950 if __name__ == '__main__':
951 import unittest
952 unittest.main(defaultTest='suite')