diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2010-12-01 00:56:10 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2010-12-01 00:56:10 (GMT) |
commit | 60901876561a4ef665555e38fae1bdfe7bda78ba (patch) | |
tree | e0f1998dfc9a106dbcef71a614e905bd475dd7db /Doc | |
parent | 00f2f97dbd3db898e5d6c2368edc780a81e2e5fe (diff) | |
download | cpython-60901876561a4ef665555e38fae1bdfe7bda78ba.zip cpython-60901876561a4ef665555e38fae1bdfe7bda78ba.tar.gz cpython-60901876561a4ef665555e38fae1bdfe7bda78ba.tar.bz2 |
#10535: Enable silenced warnings in unittest by default
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/unittest.rst | 24 | ||||
-rw-r--r-- | Doc/library/warnings.rst | 5 |
2 files changed, 25 insertions, 4 deletions
diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 6bfdd8d..1308eb4 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -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 diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst index 17e9856..03140aa 100644 --- a/Doc/library/warnings.rst +++ b/Doc/library/warnings.rst @@ -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: |