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

Classe « DocTestRunner »

Informations générales

Héritage

builtins.object
    DocTestRunner

Définition

class DocTestRunner(builtins.object):

help(DocTestRunner)

A class used to run DocTest test cases, and accumulate statistics.
The `run` method is used to process a single DocTest case.  It
returns a TestResults instance.

    >>> save_colorize = _colorize.COLORIZE
    >>> _colorize.COLORIZE = False

    >>> tests = DocTestFinder().find(_TestClass)
    >>> runner = DocTestRunner(verbose=False)
    >>> tests.sort(key = lambda test: test.name)
    >>> for test in tests:
    ...     print(test.name, '->', runner.run(test))
    _TestClass -> TestResults(failed=0, attempted=2)
    _TestClass.__init__ -> TestResults(failed=0, attempted=2)
    _TestClass.get -> TestResults(failed=0, attempted=2)
    _TestClass.square -> TestResults(failed=0, attempted=1)

The `summarize` method prints a summary of all the test cases that
have been run by the runner, and returns an aggregated TestResults
instance:

    >>> runner.summarize(verbose=1)
    4 items passed all tests:
       2 tests in _TestClass
       2 tests in _TestClass.__init__
       2 tests in _TestClass.get
       1 test in _TestClass.square
    7 tests in 4 items.
    7 passed.
    Test passed.
    TestResults(failed=0, attempted=7)

The aggregated number of tried examples and failed examples is also
available via the `tries`, `failures` and `skips` attributes:

    >>> runner.tries
    7
    >>> runner.failures
    0
    >>> runner.skips
    0

The comparison between expected outputs and actual outputs is done
by an `OutputChecker`.  This comparison may be customized with a
number of option flags; see the documentation for `testmod` for
more information.  If the option flags are insufficient, then the
comparison may also be customized by passing a subclass of
`OutputChecker` to the constructor.

The test runner's display output can be controlled in two ways.
First, an output function (`out) can be passed to
`TestRunner.run`; this function will be called with strings that
should be displayed.  It defaults to `sys.stdout.write`.  If
capturing the output is not sufficient, then the display output
can be also customized by subclassing DocTestRunner, and
overriding the methods `report_start`, `report_success`,
`report_unexpected_exception`, and `report_failure`.

    >>> _colorize.COLORIZE = save_colorize

Constructeur(s)

Signature du constructeur Description
__init__(self, checker=None, verbose=None, optionflags=0)

Liste des attributs statiques

Nom de l'attribut Valeur
DIVIDER**********************************************************************

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
merge(self, other)
report_failure(self, out, test, example, got)
report_start(self, out, test, example)
report_success(self, out, test, example, got)
report_unexpected_exception(self, out, test, example, exc_info)
run(self, test, compileflags=None, out=None, clear_globs=True)
summarize(self, verbose=None)

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé