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 Wed Mar 06 09:28:37 2013 -0600 @@ -532,25 +532,8 @@ return lambda func: func return unittest.skip("{0!r} doesn't have {1!r}".format(obj, attr)) -The following decorators implement test skipping and expected failures: - -.. decorator:: skip(reason) - - Unconditionally skip the decorated test. *reason* should describe why the - test is being skipped. - -.. decorator:: skipIf(condition, reason) - - Skip the decorated test if *condition* is true. - -.. decorator:: skipUnless(condition, reason) - - Skip the decorated test unless *condition* is true. - -.. decorator:: expectedFailure - - Mark the test as an expected failure. If the test fails when run, the test - is not counted as a failure. +The decorators which implement test skipping and expected failures are +:func:`skip`, :func:`skipIf`, :func:`skipUnless`, and :func:`expectedFailure`. Skipped tests will not have :meth:`setUp` or :meth:`tearDown` run around them. Skipped classes will not have :meth:`setUpClass` or :meth:`tearDownClass` run. @@ -1494,7 +1477,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 +1498,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 +1891,38 @@ return standard_tests +Skipping tests and expecting failures +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. decorator:: skip(reason) + + Unconditionally skip the decorated test. *reason* should describe why the + test is being skipped. + +.. decorator:: skipIf(condition, reason) + + Skip the decorated test if *condition* is true. + +.. decorator:: skipUnless(condition, reason) + + Skip the decorated test unless *condition* is true. + +.. decorator:: expectedFailure + + Mark the test as an expected failure. If the test fails when run, the test + is not counted as a failure. + +.. exception:: SkipTest(reason) + + This exception is raised to skip a test. + + Usually you can use :meth:`TestCase.skipTest()` or one of the :ref:`skipping + decorators ` instead of raising this directly. + +.. versionadded:: 3.1 :func:`skip`, :func:`skipIf`, :func:`skipUnless`, + :func:`expectedFailure`, :exc:`SkipTest` + + Class and Module Fixtures ------------------------- @@ -1968,7 +1983,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 +2000,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. diff -r b87123015fb0 Lib/unittest/case.py --- a/Lib/unittest/case.py Tue Mar 05 20:33:38 2013 +0200 +++ b/Lib/unittest/case.py Wed Mar 06 09:28:37 2013 -0600 @@ -22,7 +22,7 @@ """ Raise this exception in a test to skip it. - Usually you can use TestResult.skip() or one of the skipping decorators + Usually you can use TestCase.skipTest() or one of the skipping decorators instead of raising this directly. """