diff -r b87123015fb0 Doc/library/unittest.rst --- a/Doc/library/unittest.rst Tue Mar 05 20:33:38 2013 +0200 +++ b/Doc/library/unittest.rst Tue Mar 05 14:20:37 2013 -0600 @@ -1494,7 +1494,7 @@ If importing a module fails, for example due to a syntax error, then this will be recorded as a single error and discovery will continue. If the - import failure is due to ``SkipTest`` being raised, it will be recorded + import failure is due to :exc:`SkipTest` being raised, it will be recorded as a skip instead of an error. If a test package name (directory with :file:`__init__.py`) matches the @@ -1515,7 +1515,7 @@ .. versionadded:: 3.2 .. versionchanged:: 3.4 - Modules that raise ``SkipTest`` on import are recorded as skips, not + Modules that raise :exc:`SkipTest` on import are recorded as skips, not errors. @@ -1908,6 +1908,25 @@ return standard_tests +Skipping tests +~~~~~~~~~~~~~~ + +.. exception:: SkipTest(reason) + + Raise this exception in a test to skip it. + + Usually you can use :meth:`TestResult.skip()` or one of the :ref:`skipping + decorators ` instead of raising this directly. + +Note that this exception can be raised at any time during the execution of a +test to skip the test, including after successful assertions. In such cases, +the assertions before raising :exc:`SkipTest` are not very effective, as the +entire test will be marked as skipped. Thus, best practice is to raise +:exc:`SkipTest` before any actual testing is done. + +.. versionadded:: 3.1 + + Class and Module Fixtures ------------------------- @@ -1968,7 +1987,7 @@ If an exception is raised during a ``setUpClass`` then the tests in the class are not run and the ``tearDownClass`` is not run. Skipped classes will not have ``setUpClass`` or ``tearDownClass`` run. If the exception is a -``SkipTest`` exception then the class will be reported as having been skipped +:exc:`SkipTest` exception then the class will be reported as having been skipped instead of as an error. @@ -1985,7 +2004,7 @@ If an exception is raised in a ``setUpModule`` then none of the tests in the module will be run and the ``tearDownModule`` will not be run. If the exception is a -``SkipTest`` exception then the module will be reported as having been skipped +:exc:`SkipTest` exception then the module will be reported as having been skipped instead of as an error.