Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Module « doctest » Python 3.13.2

Fonction testmod - module doctest

Signature de la fonction testmod

def testmod(m=None, name=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False) 

Description

help(doctest.testmod)

m=None, name=None, globs=None, verbose=None, report=True,
   optionflags=0, extraglobs=None, raise_on_error=False,
   exclude_empty=False

Test examples in docstrings in functions and classes reachable
from module m (or the current module if m is not supplied), starting
with m.__doc__.

Also test examples reachable from dict m.__test__ if it exists and is
not None.  m.__test__ maps names to functions, classes and strings;
function and class docstrings are tested even if the name is private;
strings are tested directly, as if they were docstrings.

Return (#failures, #tests).

See help(doctest) for an overview.

Optional keyword arg "name" gives the name of the module; by default
use m.__name__.

Optional keyword arg "globs" gives a dict to be used as the globals
when executing examples; by default, use m.__dict__.  A copy of this
dict is actually used for each docstring, so that each docstring's
examples start with a clean slate.

Optional keyword arg "extraglobs" gives a dictionary that should be
merged into the globals that are used to execute examples.  By
default, no extra globals are used.  This is new in 2.4.

Optional keyword arg "verbose" prints lots of stuff if true, prints
only failures if false; by default, it's true iff "-v" is in sys.argv.

Optional keyword arg "report" prints a summary at the end when true,
else prints nothing at the end.  In verbose mode, the summary is
detailed, else very brief (in fact, empty if all tests passed).

Optional keyword arg "optionflags" or's together module constants,
and defaults to 0.  This is new in 2.3.  Possible values (see the
docs for details):

    DONT_ACCEPT_TRUE_FOR_1
    DONT_ACCEPT_BLANKLINE
    NORMALIZE_WHITESPACE
    ELLIPSIS
    SKIP
    IGNORE_EXCEPTION_DETAIL
    REPORT_UDIFF
    REPORT_CDIFF
    REPORT_NDIFF
    REPORT_ONLY_FIRST_FAILURE

Optional keyword arg "raise_on_error" raises an exception on the
first unexpected exception or failure. This allows failures to be
post-mortem debugged.

Advanced tomfoolery:  testmod runs methods of a local instance of
class doctest.Tester, then merges the results into (or creates)
global Tester instance doctest.master.  Methods of doctest.master
can be called directly too, if you want to do something unusual.
Passing report=0 to testmod is especially useful then, to delay
displaying a summary.  Invoke doctest.master.summarize(verbose)
when you're done fiddling.


Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé