|
| 1 | +:keepdoctest: |
| 2 | + |
1 | 3 | :mod:`doctest` --- Test interactive Python examples |
2 | 4 | =================================================== |
3 | 5 |
|
@@ -674,53 +676,36 @@ above. |
674 | 676 | An example's doctest directives modify doctest's behavior for that single |
675 | 677 | example. Use ``+`` to enable the named behavior, or ``-`` to disable it. |
676 | 678 |
|
677 | | -.. note:: |
678 | | - Due to an `unfortunate limitation`_ of our current documentation |
679 | | - publishing process, syntax highlighting has been disabled in the examples |
680 | | - below in order to ensure the doctest directives are correctly displayed. |
681 | | - |
682 | | - .. _unfortunate limitation: http://bugs.python.org/issue12947 |
| 679 | +For example, this test passes:: |
683 | 680 |
|
684 | | -For example, this test passes: |
685 | | - |
686 | | -.. code-block:: text |
687 | | -
|
688 | | - >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE |
| 681 | + >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE |
689 | 682 | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
690 | 683 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] |
691 | 684 |
|
692 | 685 | Without the directive it would fail, both because the actual output doesn't have |
693 | 686 | two blanks before the single-digit list elements, and because the actual output |
694 | 687 | is on a single line. This test also passes, and also requires a directive to do |
695 | | -so: |
696 | | - |
697 | | -.. code-block:: text |
| 688 | +so:: |
698 | 689 |
|
699 | 690 | >>> print(list(range(20))) # doctest: +ELLIPSIS |
700 | 691 | [0, 1, ..., 18, 19] |
701 | 692 |
|
702 | 693 | Multiple directives can be used on a single physical line, separated by |
703 | | -commas: |
704 | | - |
705 | | -.. code-block:: text |
| 694 | +commas:: |
706 | 695 |
|
707 | 696 | >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE |
708 | 697 | [0, 1, ..., 18, 19] |
709 | 698 |
|
710 | 699 | If multiple directive comments are used for a single example, then they are |
711 | | -combined: |
712 | | - |
713 | | -.. code-block:: text |
| 700 | +combined:: |
714 | 701 |
|
715 | 702 | >>> print(list(range(20))) # doctest: +ELLIPSIS |
716 | 703 | ... # doctest: +NORMALIZE_WHITESPACE |
717 | 704 | [0, 1, ..., 18, 19] |
718 | 705 |
|
719 | 706 | As the previous example shows, you can add ``...`` lines to your example |
720 | 707 | containing only directives. This can be useful when an example is too long for |
721 | | -a directive to comfortably fit on the same line: |
722 | | - |
723 | | -.. code-block:: text |
| 708 | +a directive to comfortably fit on the same line:: |
724 | 709 |
|
725 | 710 | >>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40))) |
726 | 711 | ... # doctest: +ELLIPSIS |
|
0 commit comments