Skip to content

Commit 6bc4120

Browse files
committed
move section below NORMALIZE_WHITESPACE instead
1 parent 3b13872 commit 6bc4120

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

Doc/library/doctest.rst

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -620,53 +620,6 @@ doctest decides whether actual output matches an example's expected output:
620620
using :data:`IGNORE_LINEBREAK` or :data:`ELLIPSIS`.
621621

622622

623-
.. index:: single: ...; in doctests
624-
.. data:: ELLIPSIS
625-
626-
When specified, an ellipsis marker (``...``) in the expected output can match
627-
any substring in the actual output. This includes substrings that span line
628-
boundaries, and empty substrings, so it's best to keep usage of this simple.
629-
Complicated uses can lead to the same kinds of "oops, it matched too much!"
630-
surprises that ``.*`` is prone to in regular expressions.
631-
632-
633-
.. data:: IGNORE_EXCEPTION_DETAIL
634-
635-
When specified, doctests expecting exceptions pass so long as an exception
636-
of the expected type is raised, even if the details
637-
(message and fully qualified exception name) don't match.
638-
639-
For example, an example expecting ``ValueError: 42`` will pass if the actual
640-
exception raised is ``ValueError: 3*14``, but will fail if, say, a
641-
:exc:`TypeError` is raised instead.
642-
It will also ignore any fully qualified name included before the
643-
exception class, which can vary between implementations and versions
644-
of Python and the code/libraries in use.
645-
Hence, all three of these variations will work with the flag specified:
646-
647-
.. code-block:: pycon
648-
649-
>>> raise Exception('message')
650-
Traceback (most recent call last):
651-
Exception: message
652-
653-
>>> raise Exception('message')
654-
Traceback (most recent call last):
655-
builtins.Exception: message
656-
657-
>>> raise Exception('message')
658-
Traceback (most recent call last):
659-
__main__.Exception: message
660-
661-
Note that :const:`ELLIPSIS` can also be used to ignore the
662-
details of the exception message, but such a test may still fail based
663-
on whether the module name is present or matches exactly.
664-
665-
.. versionchanged:: 3.2
666-
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
667-
to the module containing the exception under test.
668-
669-
670623
.. data:: IGNORE_LINEBREAK
671624

672625
When specified, single line breaks in the expected output are eliminated,
@@ -717,6 +670,53 @@ doctest decides whether actual output matches an example's expected output:
717670
.. versionadded:: next
718671

719672

673+
.. index:: single: ...; in doctests
674+
.. data:: ELLIPSIS
675+
676+
When specified, an ellipsis marker (``...``) in the expected output can match
677+
any substring in the actual output. This includes substrings that span line
678+
boundaries, and empty substrings, so it's best to keep usage of this simple.
679+
Complicated uses can lead to the same kinds of "oops, it matched too much!"
680+
surprises that ``.*`` is prone to in regular expressions.
681+
682+
683+
.. data:: IGNORE_EXCEPTION_DETAIL
684+
685+
When specified, doctests expecting exceptions pass so long as an exception
686+
of the expected type is raised, even if the details
687+
(message and fully qualified exception name) don't match.
688+
689+
For example, an example expecting ``ValueError: 42`` will pass if the actual
690+
exception raised is ``ValueError: 3*14``, but will fail if, say, a
691+
:exc:`TypeError` is raised instead.
692+
It will also ignore any fully qualified name included before the
693+
exception class, which can vary between implementations and versions
694+
of Python and the code/libraries in use.
695+
Hence, all three of these variations will work with the flag specified:
696+
697+
.. code-block:: pycon
698+
699+
>>> raise Exception('message')
700+
Traceback (most recent call last):
701+
Exception: message
702+
703+
>>> raise Exception('message')
704+
Traceback (most recent call last):
705+
builtins.Exception: message
706+
707+
>>> raise Exception('message')
708+
Traceback (most recent call last):
709+
__main__.Exception: message
710+
711+
Note that :const:`ELLIPSIS` can also be used to ignore the
712+
details of the exception message, but such a test may still fail based
713+
on whether the module name is present or matches exactly.
714+
715+
.. versionchanged:: 3.2
716+
:const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information relating
717+
to the module containing the exception under test.
718+
719+
720720
.. data:: SKIP
721721

722722
When specified, do not run the example at all. This can be useful in contexts

0 commit comments

Comments
 (0)