#10535: Enable silenced warnings in unittest by default

This commit is contained in:
Ezio Melotti 2010-12-01 00:56:10 +00:00
parent 00f2f97dbd
commit 6090187656
8 changed files with 228 additions and 22 deletions

View file

@ -1845,12 +1845,21 @@ Loading and running tests
instead of repeatedly creating new instances.
.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1, runnerclass=None)
.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1, runnerclass=None, warnings=None)
A basic test runner implementation which prints results on standard error. It
has a few configurable parameters, but is essentially very simple. Graphical
applications which run test suites should provide alternate implementations.
By default this runner shows :exc:`DeprecationWarning`,
:exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` even if they are
:ref:`ignored by default <warning-ignored>`. Deprecation warnings caused by
:ref:`deprecated unittest methods <deprecated-aliases>` are also
special-cased and, when the warning filters are ``'default'`` or ``'always'``,
they will appear only once per-module, in order to avoid too many warning
messages. This behavior can be overridden using the :option`-Wd` or
:option:`-Wa` options and leaving *warnings* to ``None``.
.. method:: _makeResult()
This method returns the instance of ``TestResult`` used by :meth:`run`.
@ -1864,7 +1873,9 @@ Loading and running tests
stream, descriptions, verbosity
.. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.loader.defaultTestLoader, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None)
.. versionchanged:: 3.2 Added the ``warnings`` argument
.. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.loader.defaultTestLoader, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None, warnings=None)
A command-line program that runs a set of tests; this is primarily for making
test modules conveniently executable. The simplest use for this function is to
@ -1893,12 +1904,17 @@ Loading and running tests
The ``failfast``, ``catchbreak`` and ``buffer`` parameters have the same
effect as the same-name `command-line options`_.
The *warning* argument specifies the :ref:`warning filter <warning-filter>`
that should be used while running the tests. If it's not specified, it will
remain ``None`` if a :option:`-W` option is passed to :program:`python`,
otherwise it will be set to ``'default'``.
Calling ``main`` actually returns an instance of the ``TestProgram`` class.
This stores the result of the tests run as the ``result`` attribute.
.. versionchanged:: 3.2
The ``exit``, ``verbosity``, ``failfast``, ``catchbreak`` and ``buffer``
parameters were added.
The ``exit``, ``verbosity``, ``failfast``, ``catchbreak``, ``buffer``,
and ``warnings`` parameters were added.
load_tests Protocol

View file

@ -249,6 +249,8 @@ continues to increase after each operation, or else delete the previous
entries from the warnings list before each new operation).
.. _warning-ignored:
Updating Code For New Versions of Python
----------------------------------------
@ -279,6 +281,9 @@ code that were not there in an older interpreter, e.g.
developer want to be notified that your code is using a deprecated module, to a
user this information is essentially noise and provides no benefit to them.
The :mod:`unittest` module has been also updated to use the ``'default'``
filter while running tests.
.. _warning-functions: