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