@@ -714,36 +714,51 @@ above.
714714An example's doctest directives modify doctest's behavior for that single
715715example. Use ``+ `` to enable the named behavior, or ``- `` to disable it.
716716
717- For example, this test passes::
717+ For example, this test passes:
718718
719- >>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
719+ .. doctest ::
720+ :no-trim-doctest-flags:
721+
722+ >>> print (list (range (20 ))) # doctest: +NORMALIZE_WHITESPACE
720723 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
721724 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
722725
723726Without the directive it would fail, both because the actual output doesn't have
724727two blanks before the single-digit list elements, and because the actual output
725728is on a single line. This test also passes, and also requires a directive to do
726- so::
729+ so:
730+
731+ .. doctest ::
732+ :no-trim-doctest-flags:
727733
728- >>> print(list(range(20))) # doctest: +ELLIPSIS
734+ >>> print (list (range (20 ))) # doctest: +ELLIPSIS
729735 [0, 1, ..., 18, 19]
730736
731737Multiple directives can be used on a single physical line, separated by
732- commas::
738+ commas:
733739
734- >>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
740+ .. doctest ::
741+ :no-trim-doctest-flags:
742+
743+ >>> print (list (range (20 ))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
735744 [0, 1, ..., 18, 19]
736745
737746If multiple directive comments are used for a single example, then they are
738- combined::
747+ combined:
748+
749+ .. doctest ::
750+ :no-trim-doctest-flags:
739751
740- >>> print(list(range(20))) # doctest: +ELLIPSIS
741- ... # doctest: +NORMALIZE_WHITESPACE
752+ >>> print (list (range (20 ))) # doctest: +ELLIPSIS
753+ ... # doctest: +NORMALIZE_WHITESPACE
742754 [0, 1, ..., 18, 19]
743755
744756As the previous example shows, you can add ``... `` lines to your example
745757containing only directives. This can be useful when an example is too long for
746- a directive to comfortably fit on the same line::
758+ a directive to comfortably fit on the same line:
759+
760+ .. doctest ::
761+ :no-trim-doctest-flags:
747762
748763 >>> print (list (range (5 )) + list (range (10 , 20 )) + list (range (30 , 40 )))
749764 ... # doctest: +ELLIPSIS
@@ -783,18 +798,23 @@ instead. Another is to do ::
783798
784799There are others, but you get the idea.
785800
786- Another bad idea is to print things that embed an object address, like ::
801+ Another bad idea is to print things that embed an object address, like
802+
803+ .. doctest ::
787804
788- >>> id(1.0) # certain to fail some of the time
805+ >>> id (1.0 ) # certain to fail some of the time # doctest: +SKIP
789806 7948648
790807 >>> class C : pass
791- >>> C() # the default repr() for instances embeds an address
792- <__main__.C instance at 0x00AC18F0>
808+ >>> C() # the default repr() for instances embeds an address # doctest: +SKIP
809+ <C object at 0x00AC18F0>
810+
811+ The :const: `ELLIPSIS ` directive gives a nice approach for the last example:
793812
794- The :const: `ELLIPSIS ` directive gives a nice approach for the last example::
813+ .. doctest ::
814+ :no-trim-doctest-flags:
795815
796- >>> C() # doctest: +ELLIPSIS
797- <__main__.C instance at 0x...>
816+ >>> C() # doctest: +ELLIPSIS
817+ <C object at 0x...>
798818
799819Floating-point numbers are also subject to small output variations across
800820platforms, because Python defers to the platform C library for float formatting,
0 commit comments